
    <e                    B   d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlmZ ddlmZmZ ddlmZ ddlmZ ddlZd Zd Zd	 ZdzdZ G d d          Z ej        ddg          Z ej        ddg          Z G d dej                  Z G d dej                  Z  G d dej                  Z! G d dej                  Z" G d dej                  Z# G d dej                  Z$ G d d ej                  Z% G d! d"ej                  Z& G d# d$ej                  Z' G d% d&ej                  Z( G d' d(ej                  Z) G d) d*ej                  Z* G d+ d,ej                  Z+ G d- d.ej                  Z, G d/ d0ej                  Z- G d1 d2ej                  Z. G d3 d4ej                  Z/ G d5 d6ej                  Z0 G d7 d8ej                  Z1 G d9 d:          Z2 G d; d<          Z3 G d= d>e2e3          Z4 G d? d@e           Z5 G dA dBe           Z6 G dC dDe           Z7 G dE dFe2          Z8 G dG dHe e8e3          Z9 G dI dJe e8e3          Z: G dK dLe e8          Z; G dM dNe e3          Z< G dO dPe;e3          Z= G dQ dRe;e3          Z> G dS dTe;          Z? G dU dVe e8e3          Z@ G dW dXej                  ZA G dY dZej                  ZB G d[ d\e2          ZC G d] d^eCe e3          ZD G d_ d`eCe e3          ZE G da dbeCe           ZF G dc ddej                  ZG G de dfeCe           ZH G dg dhej                  ZI G di djej                  ZJ G dk dlej                  ZK G dm dnej                  ZL G do dpej                  ZM G dq dr          ZN G ds dtej        eN          ZO ejP        edu           G dv dwej        eN                      ZQdx ZReSdyk    r ejT                     dS dS ){z_Test suite for statistics module, including helper NumericTestCase and
approx_equal function.

    N)support)import_helperrequires_IEEE_754)DecimalFractionc                 ,    t          j        d|           S )z:Return -1.0 for negatives, including -0.0, otherwise +1.0.   )mathcopysignxs    +/usr/lib/python3.11/test/test_statistics.pysignr      s    =A    c                 8   t          |           t          |          urdS t          | t                    r(t          j        |           ot          j        |          S |                                 d         }|                                d         }||k    o|dv S )a  Return True if a and b are both the same kind of NAN.

    >>> _nan_equal(Decimal('NAN'), Decimal('NAN'))
    True
    >>> _nan_equal(Decimal('sNAN'), Decimal('sNAN'))
    True
    >>> _nan_equal(Decimal('NAN'), Decimal('sNAN'))
    False
    >>> _nan_equal(Decimal(42), Decimal('NAN'))
    False

    >>> _nan_equal(float('NAN'), float('NAN'))
    True
    >>> _nan_equal(float('NAN'), 0.5)
    False

    >>> _nan_equal(float('NAN'), Decimal('NAN'))
    False

    NAN payloads are not compared.
    F   )nN)type
isinstancefloatr   isnanas_tuple)abaexpbexps       r   
_nan_equalr   #   s    , Awwd1ggu!U /z!}}.A.::<<?D::<<?DDL2tz12r   c                     t          t          |           t          |                    }t          | |z
            }|r||z  nt          d          }||fS )zReturn the absolute and relative errors between two numbers.

    >>> _calc_errors(100, 75)
    (25, 0.25)
    >>> _calc_errors(100, 100)
    (0, 0.0)

    Returns the (absolute error, relative error) between the two arguments.
    inf)maxabsr   )actualexpectedbaseabs_errrel_errs        r   _calc_errorsr)   B   sT     s6{{CMM**D&8#$$G"4gdlleGWr   -q=Hz>c           
         |dk     s|dk     rt          d          t          j        |           st          j        |          rdS | |k    rdS t          j        |           st          j        |          rdS t	          | |z
            }t          ||t          t	          |           t	          |                    z            }||k    S )a  approx_equal(x, y [, tol [, rel]]) => True|False

    Return True if numbers x and y are approximately equal, to within some
    margin of error, otherwise return False. Numbers which compare equal
    will also compare approximately equal.

    x is approximately equal to y if the difference between them is less than
    an absolute error tol or a relative error rel, whichever is bigger.

    If given, both tol and rel must be finite, non-negative numbers. If not
    given, default values are tol=1e-12 and rel=1e-7.

    >>> approx_equal(1.2589, 1.2587, tol=0.0003, rel=0)
    True
    >>> approx_equal(1.2589, 1.2587, tol=0.0001, rel=0)
    False

    Absolute error is defined as abs(x-y); if that is less than or equal to
    tol, x and y are considered approximately equal.

    Relative error is defined as abs((x-y)/x) or abs((x-y)/y), whichever is
    smaller, provided x or y are not zero. If that figure is less than or
    equal to rel, x and y are considered approximately equal.

    Complex numbers are not directly supported. If you wish to compare to
    complex numbers, extract their real and imaginary parts and compare them
    individually.

    NANs always compare unequal, even with themselves. Infinities compare
    approximately equal if they have the same sign (both positive or both
    negative). Infinities with different signs compare unequal; so do
    comparisons of infinities with finite numbers.
    r   z%error tolerances must be non-negativeFT)
ValueErrorr   r   isinfr#   r"   )r   ytolrelactual_errorallowed_errors         r   approx_equalr4   R   s    D Qww#''@AAAz!}} 
1 uAvvtz!}} 
1  uq1u::LSSVVSVV!4!4455M=((r   c                       e Zd ZdZdS )
_DoNothinga  
    When doing numeric work, especially with floats, exact equality is often
    not what you want. Due to round-off error, it is often a bad idea to try
    to compare floats with equality. Instead the usual procedure is to test
    them with some (hopefully small!) allowance for error.

    The ``approx_equal`` function allows you to specify either an absolute
    error tolerance, or a relative error, or both.

    Absolute error tolerances are simple, but you need to know the magnitude
    of the quantities being compared:

    >>> approx_equal(12.345, 12.346, tol=1e-3)
    True
    >>> approx_equal(12.345e6, 12.346e6, tol=1e-3)  # tol is too small.
    False

    Relative errors are more suitable when the values you are comparing can
    vary in magnitude:

    >>> approx_equal(12.345, 12.346, rel=1e-4)
    True
    >>> approx_equal(12.345e6, 12.346e6, rel=1e-4)
    True

    but a naive implementation of relative error testing can run into trouble
    around zero.

    If you supply both an absolute tolerance and a relative error, the
    comparison succeeds if either individual test succeeds:

    >>> approx_equal(12.345e6, 12.346e6, tol=1e-3, rel=1e-4)
    True

    N)__name__
__module____qualname____doc__ r   r   r6   r6      s        " "F 	Dr   r6   
statistics_statistics)blocked)freshc                   N    e Zd ZdgZd Z ej        ed          d             ZdS )TestModules_normal_dist_inv_cdfc                 v    | j         D ]0}|                     t          t          |          j        d           1d S Nr<   )
func_namesassertEqualgetattrpy_statisticsr8   selffnames     r   test_py_functionszTestModules.test_py_functions   sG    _ 	U 	UEW]E::E|TTTT	U 	Ur   requires _statisticsc                 v    | j         D ]0}|                     t          t          |          j        d           1d S )Nr=   )rE   rF   rG   c_statisticsr8   rI   s     r   test_c_functionszTestModules.test_c_functions   sG    _ 	U 	UEW\599DmTTTT	U 	Ur   N)	r7   r8   r9   rE   rL   unittest
skipUnlessrO   rP   r;   r   r   rA   rA      s_        ()JU U U X'=>>U U ?>U U Ur   rA   c                   H    e Zd ZdZdxZZ	 ddZd Zd	dZe	d             Z
dS )
NumericTestCasezUnit test class for numeric work.

    This subclasses TestCase. In addition to the standard method
    ``TestCase.assertAlmostEqual``,  ``assertApproxEqual`` is provided.
    r   Nc                     || j         }|| j        }t          |t          j        j                  r't          |t          j        j                  r| j        }n| j        } ||||||           dS )a  Test passes if ``first`` and ``second`` are approximately equal.

        This test passes if ``first`` and ``second`` are equal to
        within ``tol``, an absolute error, or ``rel``, a relative error.

        If either ``tol`` or ``rel`` are None or not given, they default to
        test attributes of the same name (by default, 0).

        The objects may be either numbers, or sequences of numbers. Sequences
        are tested element-by-element.

        >>> class MyTest(NumericTestCase):
        ...     def test_number(self):
        ...         x = 1.0/6
        ...         y = sum([x]*6)
        ...         self.assertApproxEqual(y, 1.0, tol=1e-15)
        ...     def test_sequence(self):
        ...         a = [1.001, 1.001e-10, 1.001e10]
        ...         b = [1.0, 1e-10, 1e10]
        ...         self.assertApproxEqual(a, b, rel=1e-3)
        ...
        >>> import unittest
        >>> from io import StringIO  # Suppress test runner output.
        >>> suite = unittest.TestLoader().loadTestsFromTestCase(MyTest)
        >>> unittest.TextTestRunner(stream=StringIO()).run(suite)
        <unittest.runner.TextTestResult run=2 errors=0 failures=0>

        N)r0   r1   r   collectionsabcSequence_check_approx_seq_check_approx_num)rJ   firstsecondr0   r1   msgchecks          r   assertApproxEqualz!NumericTestCase.assertApproxEqual   s|    > ;(C;(C5+/":;;	+6;?#;<<	+ *EE*EeVS#s+++++r   c           	      ^   t          |          t          |          k    rLdt          |          t          |          fz  }|                     ||          }|                     |          t          t	          ||                    D ]"\  }\  }}	|                     ||	||||           #d S )Nz0sequences differ in length: %d items != %d items)len_formatMessagefailureException	enumerateziprZ   )
rJ   r[   r\   r0   r1   r]   standardMsgir   es
             r   rY   z!NumericTestCase._check_approx_seq   s    u::V$$Bu::s6{{+,  %%c;77C'',,,!#eV"4"455 	; 	;HAu!""1ac3::::	; 	;r   c                     t          ||||          rd S |                     |||||          }|                     ||          }|                     |          N)r4   _make_std_err_msgrb   rc   )rJ   r[   r\   r0   r1   r]   idxrf   s           r   rZ   z!NumericTestCase._check_approx_num
  sa    vsC00 	4,,UFCcJJ!!#{33##C(((r   c                 Z    d}|
d|z  }||z   }t          | |          \  }}|| |||||fz  S )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\   r0   r1   rl   templateheaderr'   r(   s	            r   rk   z!NumericTestCase._make_std_err_msg  sS    
' 	 ?DsJF(H'v665&#sGWEEEr   )NNNrj   )r7   r8   r9   r:   r0   r1   r_   rY   rZ   staticmethodrk   r;   r   r   rT   rT      s          MC# :>*, *, *, *,X	; 	; 	;) ) ) ) F F \F F Fr   rT   c                       e Zd ZdZd ZdS )TestSignz5Test that the helper function sign() works correctly.c                     |                      t          d          d           |                      t          d          d           d S )N        r
   g       )rF   r   rJ   s    r   
testZeroeszTestSign.testZeroes+  s@    cB'''dR(((((r   N)r7   r8   r9   r:   rw   r;   r   r   rr   rr   )  s)        ??) ) ) ) )r   rr   c                   &    e Zd Zd Zd Zd Zd ZdS )ApproxEqualSymmetryTestc                     dddt          d          t          dd          g}ddd	t          d
          t          dd          g}t          ||          D ]\  }}|                     ||           d S )Ni	  gfffffB@gfffff(z2.54   6   i	  gB@gR(z2.59   )r   r   re   do_relative_symmetry)rJ   args1args2r   r   s        r   test_relative_symmetryz.ApproxEqualSymmetryTest.test_relative_symmetry6  s     tVWV__hr26F6FGtVWV__hr26F6FGu%% 	, 	,DAq%%a++++	, 	,r   c                 @   t          ||          t          ||          }}||z
  }t          ||z            t          ||z            }}||z   dz  }|                     t	          ||d|                     |                     t	          ||d|                     d S )Nr   r   r0   r1   )minr"   r#   
assertTruer4   )rJ   r   r   deltarel_err1rel_err2r1   s          r   r~   z,ApproxEqualSymmetryTest.do_relative_symmetryF  s    1ayy#a))1A q\\3uQw<<(("A% 	Qqc:::;;;Qqc:::;;;;;r   c           	         g d}d}|D ]5}t           t          t          t          fD ]} ||          dz  }||z   }t	          |t          ||          z            }|                     ||||           |                     |||dz   d|z             |                     |||dz
  |dz             |                     ||||dz             |                     |||dz
  |           |                     |||dz
  d|z             |                     ||dd           |                     ||dd           7d S )N)i   k   im r   d   r   r
   r   )intr   r   r   r#   r"   do_symmetry_test)rJ   argsr   r   type_r   r/   rs           r   test_symmetryz%ApproxEqualSymmetryTest.test_symmetryR  s   ''' 	: 	:Augx8 : :E!HHSLIc!Qii(( %%a1%===%%aaQqS%AAA%%aaQqS%AAA%%a1Q3%???%%aaQ%???%%aaQqS%AAA%%aq%999%%aq%9999#:	: 	:r   c           
          d}t          ||||          }t          ||||          }|                     |||                    ||||f                     d S )Nz+approx_equal comparisons don't match for %r)r4   rF   format)rJ   r   r   r0   r1   rn   flag1flag2s           r   r   z(ApproxEqualSymmetryTest.do_symmetry_testj  s`    @Q3,,Q3,,x1c37G'H'HIIIIIr   N)r7   r8   r9   r   r~   r   r   r;   r   r   ry   ry   3  sU        , , , 
< 
< 
<: : :0J J J J Jr   ry   c                   D    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )ApproxEqualExactTestc                     t          ||||          }|                     |d|z             t          | | ||          }|                     |d| z             d S )Nr   zequality failure for x=%r)r4   r   )rJ   r   r0   r1   results        r   do_exactly_equal_testz*ApproxEqualExactTest.do_exactly_equal_testw  sn    a555 ;a ?@@@qb1"#3777 ;qb @AAAAAr   c                 >    dD ]}|                      |dd           d S )N)*   iM  i~:     i  iU
 i  r   r   rJ   r   s     r   test_exactly_equal_intsz,ApproxEqualExactTest.test_exactly_equal_ints}  s6    = 	0 	0A&&q!Q////	0 	0r   c                 >    dD ]}|                      |dd           d S )N)gzG?g/$?ge@g      7@g     pf@g!rhQ@gB`"KB@r   r   rJ   r   s     r   test_exactly_equal_floatsz.ApproxEqualExactTest.test_exactly_equal_floats  s6    E 	0 	0A&&q!Q////	0 	0r   c           	          t           } |dd           |d           |dd           |dd           |dd	           |dd          fD ]}|                     |dd           d S )
Nr
   r   r   r      	      #   $   )r   r   rJ   Ffs      r   test_exactly_equal_fractionsz1ApproxEqualExactTest.test_exactly_equal_fractions  s    !Aq''11Q441a!!Aq''11R99aa1ggF 	0 	0A&&q!Q////	0 	0r   c                     t           }t          |d                                          D ]}|                     |dd           d S )Nz8.2 31.274 912.04 16.745 1.2047r   )r   mapsplitr   )rJ   Dds      r   test_exactly_equal_decimalsz0ApproxEqualExactTest.test_exactly_equal_decimals  sR    Q9??AABB 	0 	0A&&q!Q////	0 	0r   c                     dD ]Z}|                      |dd           |                      |dz  dd           t          |d          }|                      |dd           [d S )N)   i  i\  i  i     {Gz?r   
   i  )r   r   )rJ   r   r   s      r   test_exactly_equal_absolutez0ApproxEqualExactTest.test_exactly_equal_absolute  sy    / 	3 	3A&&q$222&&qtT1555D!!A&&q$2222	3 	3r   c                     |                      t          d          t          d          d           |                      t          d           t          d          d           d S )Nz3.5710.01r   z81.3971)r   r   rv   s    r   $test_exactly_equal_absolute_decimalsz9ApproxEqualExactTest.test_exactly_equal_absolute_decimals  sW    ""77#3#3WV__aHHH""GI$6$6#6KKKKKr   c                     dddt          dd          fD ]}|                     |dd           |                     t          d          dt          d	                     d S )
Ni   g33333SY@gzGr      r   r   z11.68r   r   r   r   r   s     r   test_exactly_equal_relativez0ApproxEqualExactTest.test_exactly_equal_relative  si    x!R9 	3 	3A&&q!T2222""77#3#3QHHHHHr   c                     dddt          dd          fD ]}|                     |dd           t          }|                      |d           |d	           |d
                     d S )Ni9  gˡE0@g\(hr      皙?r   z7.2z0.1r   r   )rJ   r   r   s      r   test_exactly_equal_bothz,ApproxEqualExactTest.test_exactly_equal_both  sx    (1a..9 	5 	5A&&q#t4444""11U88QQuXXqqyyAAAAAr   N)r7   r8   r9   r   r   r   r   r   r   r   r   r   r;   r   r   r   r   q  s        B B B0 0 0
0 0 0
0 0 00 0 0	3 	3 	3L L L
I I IB B B B Br   r   c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )ApproxEqualUnequalTestc                 t    || fD ]1}t          ||dz   dd          }|                     |d|z             2d S )Nr
   r   r   zinequality failure for x=%r)r4   assertFalse)rJ   r   r   r   s       r   do_exactly_unequal_testz.ApproxEqualUnequalTest.do_exactly_unequal_test  s^    aR 	H 	HA!!QqSaQ777FV%BQ%FGGGG	H 	Hr   c                 :    dD ]}|                      |           d S )N)i  i i  i  iXC  r   r   s     r   test_exactly_unequal_intsz0ApproxEqualUnequalTest.test_exactly_unequal_ints  s2    / 	, 	,A((++++	, 	,r   c                 :    dD ]}|                      |           d S )N)gQ#@g[@gfffffG@gףp=
W"@g=
ףp=1@r   r   s     r   test_exactly_unequal_floatsz2ApproxEqualUnequalTest.test_exactly_unequal_floats  s2    3 	, 	,A((++++	, 	,r   c                     t           } |dd           |dd           |dd           |dd          fD ]}|                     |           d S )	Nr
   r   r   r         e   iς )r   r   r   s      r   test_exactly_unequal_fractionsz5ApproxEqualUnequalTest.test_exactly_unequal_fractions  sh    !Aq''11Q77AAb"IIqqe}}= 	, 	,A((++++	, 	,r   c                     t          t          d                                          D ]}|                     |           d S )Nz!3.1415 298.12 3.47 18.996 0.00245)r   r   r   r   rJ   r   s     r   test_exactly_unequal_decimalsz4ApproxEqualUnequalTest.test_exactly_unequal_decimals  sI    WAGGIIJJ 	, 	,A((++++	, 	,r   N)r7   r8   r9   r   r   r   r   r   r;   r   r   r   r     sb        H H H
, , ,
, , ,
, , ,, , , , ,r   r   c                   n    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd ZdS )ApproxEqualInexactTestc           	          d}||z   ||z
  fD ]l}|                     ||          }|                     t          ||d|z  d          |           |                     t          |||dz  d          |           md S )NTest failure for x={!r}, y={!r}r   r   r   r   r   r4   r   rJ   r   r   rn   r/   r]   s         r   do_approx_equal_abs_testz/ApproxEqualInexactTest.do_approx_equal_abs_test  s    4e)QY' 	J 	JA//!Q''COOLA1U7BBBCHHH\!QE!GCCCSIIII	J 	Jr   c                 h    dD ].}|                      |d           |                      |d           /d S )N)iiIir   r   r
   r   %   i  i&  i6jr   r   r   r   s     r   test_approx_equal_absolute_intsz6ApproxEqualInexactTest.test_approx_equal_absolute_ints  sJ    J 	0 	0A))!R000))!Q////	0 	0r   c                     dD ]D}|                      |d           |                      |d           |                      |d           Ed S )N)	gtqgfffffFXg333333g333333      ?      ?g333333@gQ@gҭ@      ?r   -C6?r   r   s     r   !test_approx_equal_absolute_floatsz8ApproxEqualInexactTest.test_approx_equal_absolute_floats  s`    L 	5 	5A))!S111))!T222))!V4444	5 	5r   c                     t          dd          }g d}d |D             D ];}|                     ||           |                     |t          |                     <d S )Nr
      )ir   ru   r   r
   r   r{      "   G   c              3   6   K   | ]}t          |d           V  dS )r   Nr   ).0r   s     r   	<genexpr>zNApproxEqualInexactTest.test_approx_equal_absolute_fractions.<locals>.<genexpr>  s*      66a(1b//666666r   )r   r   r   )rJ   r   
numeratorsr   s       r   $test_approx_equal_absolute_fractionsz;ApproxEqualInexactTest.test_approx_equal_absolute_fractions  sv    B@@@
66:666 	; 	;A))!U333))!U5\\::::	; 	;r   c                     t          d          }t          t           d                                          D ]/}|                     ||           |                     | |           0d S )Nr   z1.0 3.5 36.08 61.79 7912.3648)r   r   r   r   )rJ   r   r   s      r   #test_approx_equal_absolute_decimalsz:ApproxEqualInexactTest.test_approx_equal_absolute_decimals  sn    W=CCEEFF 	5 	5A))!U333))1"e4444	5 	5r   c                 R    |                      t          dddd                     d S )Ngh㈵>gh㈵r   r   r   )r   r4   rv   s    r   test_cross_zeroz&ApproxEqualInexactTest.test_cross_zero  s+    T5dBBBCCCCCr   c           
         d}|d|z   z  |d|z
  z  fD ]l}|                     ||          }|                     t          ||dd|z            |           |                     t          ||d|dz            |           md S )Nr   r
   r   r   r   r   r   s         r   do_approx_equal_rel_testz/ApproxEqualInexactTest.do_approx_equal_rel_test  s    4QuW+q!E'{+ 	J 	JA//!Q''COOLA1!E'BBBCHHH\!QA57CCCSIIII	J 	Jr   c                    |                      t          dddd                     |                      t          dddd                     |                      t          dddd	                     |                      t          d
ddd	                     |                     t          dddd	                     d S )N@   /   r   g
ףp=
?r   gGz?i  i         ?i  i  )r   r4   r   rv   s    r   test_approx_equal_relative_intsz6ApproxEqualInexactTest.test_approx_equal_relative_ints  s    R===>>>R===>>>S#1%@@@AAAS#1%@@@AAAc3A5AAABBBBBr   c                 h    dD ].}|                      |d           |                      |d           /d S )N)g{GJf皙r   r   g\(|B@gʡE>@gx@{Gz?r   )r   r   s     r   !test_approx_equal_relative_floatsz8ApproxEqualInexactTest.test_approx_equal_relative_floats  sJ    E 	5 	5A))!T222))!V4444	5 	5r   c                    t           }t          dd          } |dd           |dd           |dd           |dd	          fD ]C}|t          |          fD ]/}|                     ||           |                     | |           0Dd S )
Nr   r   T   r{      1   2   \   U   )r   r   r   )rJ   r   r   r   r   s        r   $test_approx_equal_relative_fractionsz;ApproxEqualInexactTest.test_approx_equal_relative_fractions  s    A!Ar((AAb"IIqqRyy!!B))< 	5 	5AU5\\* 5 5--a333--qb!44445	5 	5r   c                     t          t          d                                          D ]I}|                     |t          d                     |                     | t          d                     Jd S )Nz$0.02 1.0 5.7 13.67 94.138 91027.93210.0010.05)r   r   r   r   r   s     r   #test_approx_equal_relative_decimalsz:ApproxEqualInexactTest.test_approx_equal_relative_decimals  sq    WDJJLLMM 	? 	?A))!WW-=-=>>>))1"gfoo>>>>	? 	?r   c                    |r| j         n| j        } |t          |||d                     |r| j         n| j        } |t          ||d|                     |s|r| j         n| j        } |t          ||||                     d S )Nr   r   )r   r   r4   )rJ   r   r   r0   r1   tol_flagrel_flagr^   s           r   do_check_bothz$ApproxEqualInexactTest.do_check_both,  s    #+A1Al1aSa000111#+A1Al1aQC000111$,OOt?Ol1aSc22233333r   c                 n    |                      dddddd           |                      dddd	dd           d S )
NR@+@Mbp?W8?Tg?5^Ig%CMb`?g-C6*?r  rv   s    r   test_approx_equal_both1z.ApproxEqualInexactTest.test_approx_equal_both14  sD    5%dCCC665&$EEEEEr   c                 :    |                      dddddd           d S )Nr  r  r  gVF?8?TFr  rv   s    r   test_approx_equal_both2z.ApproxEqualInexactTest.test_approx_equal_both29  s&    5%eDDDDDr   c                 :    |                      dddddd           d S )Nr  r  MbP?r  FTr  rv   s    r   test_approx_equal_both3z.ApproxEqualInexactTest.test_approx_equal_both3=  s&    5%tDDDDDr   c                 n    |                      dddddd           |                      dddd	dd           d S )
Ng=
ףp=@      @r   r  FgQ[@g(\[@r  giUMu>r  rv   s    r   test_approx_equal_both4z.ApproxEqualInexactTest.test_approx_equal_both4A  sD    4tUE5AAA664ueDDDDDr   N)r7   r8   r9   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r   r#  r;   r   r   r   r     s       J J J0 0 05 5 5; ; ;5 5 5D D DJ J JC C C5 5 55 5 5? ? ?4 4 4F F F
E E EE E EE E E E Er   r   c                   &    e Zd Zd Zd Zd Zd ZdS )ApproxEqualSpecialsTestc           	         t           t          fD ]} |d          }|                     t          ||                     |                     t          ||dd                     |                     t          ||dd                     |                     t          | |                      |                     t          ||                      |                     t          |d                     d S )Nr!   r   r
   r     )r   r   r   r4   r   )rJ   r   r!   s      r   test_infz ApproxEqualSpecialsTest.test_infJ  s    W% 	6 	6E%,,COOLc22333OOLc1a88999OOLc1d;;<<<OOL#t44555\#t44555\#t445555	6 	6r   c                     t           t          fD ]A} |d          }| |d          dfD ]%}|                     t          ||                     &Bd S )Nnanr!   r'  )r   r   r   r4   )rJ   r   r*  others       r   test_nanz ApproxEqualSpecialsTest.test_nanT  sq    W% 	; 	;E%,,CuuU||T2 ; ;  c5!9!9::::;	; 	;r   c                 |    t          j        dd          }|                     t          |ddd                     d S )Nrt   ru   r   r   )r   r   r   r4   rJ   nzeros     r   test_float_zeroesz)ApproxEqualSpecialsTest.test_float_zeroesZ  s<    c2&&UCScBBBCCCCCr   c                     t          d          }|                     t          |t          d          dd                     d S )Nz-0.0r   r   r   )r   r   r4   r.  s     r   test_decimal_zeroesz+ApproxEqualSpecialsTest.test_decimal_zeroes^  s<    UGAJJCSIIIJJJJJr   N)r7   r8   r9   r(  r,  r0  r2  r;   r   r   r%  r%  G  sX        6 6 6; ; ;D D DK K K K Kr   r%  c                       e Zd Zd Zd ZdS )TestApproxEqualErrorsc                 N    |                      t          t          dddd           d S )Nr   ru   r   assertRaisesr-   r4   rv   s    r   test_bad_tolz"TestApproxEqualErrors.test_bad_tolf  s&    *lCb#FFFFFr   c                 N    |                      t          t          dddd           d S )Nr   r
   r  r6  rv   s    r   test_bad_relz"TestApproxEqualErrors.test_bad_relj  s&    *lCaFFFFFr   N)r7   r8   r9   r8  r:  r;   r   r   r4  r4  c  s:        G G GG G G G Gr   r4  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )TestNumericTestCasec                 l    t          j        | } | j        | }|D ]}|                     ||           d S rj   )rT   rk   generate_substringsassertIn)rJ   r   
actual_msgr%   	substrings        r   do_testzTestNumericTestCase.do_testz  sN    $6=
+4+T2! 	1 	1IMM)Z0000	1 	1r   c                 j    |                      t          t          t          j                             d S rj   )r   
issubclassrT   rQ   TestCaserv   s    r    test_numerictestcase_is_testcasez4TestNumericTestCase.test_numerictestcase_is_testcase  s'    
?H4EFFGGGGGr   c                 4    d}|                      |           d S )N)      @      @r         ?NrB  rJ   r   s     r   test_error_msg_numericz*TestNumericTestCase.test_error_msg_numeric  s    *Tr   c                 4    d}|                      |           d S )N)      @g      @g      ?r   r   rK  rL  s     r   test_error_msg_sequencez+TestNumericTestCase.test_error_msg_sequence  s    )Tr   c                     t          ||          \  }}d|z  d|z  d|z  d|z  g}||                    d|z             |S )z5Return substrings we expect to see in error messages.ztol=%rzrel=%rzabsolute error = %rzrelative error = %rNzdiffer at index %d)r)   append)	rJ   r[   r\   r0   r1   rl   r'   r(   
substringss	            r   r>  z'TestNumericTestCase.generate_substrings  sb    'v6633%/%/	
 ?2S8999r   N)r7   r8   r9   rB  rF  rM  rP  r>  r;   r   r   r<  r<  t  sb        1 1 1H H H  
  
    r   r<  c                   &    e Zd ZeZddgZd Zd ZdS )GlobalsTestr:   __all__c                 r    | j         D ].}|                     t          | j        |          d|z             /d S )Nz%s not present)expected_metadatar   hasattrmodule)rJ   metas     r   	test_metazGlobalsTest.test_meta  sO    * 	5 	5DOOGDK66,t35 5 5 5	5 	5r   c                     | j         }|j        D ]U}|                     |                    d          d|z             |                     t          ||          d|z             Vd S )N_zprivate name "%s" in __all__zmissing name "%s" in __all__)rZ  rV  r   
startswithr   rY  )rJ   rZ  names      r   test_check_allzGlobalsTest.test_check_all  s    N 	C 	CDT__S11;dBD D D OOGFD11:TAC C C C	C 	Cr   N)r7   r8   r9   r<   rZ  rX  r\  ra  r;   r   r   rU  rU    sG        F"I.5 5 5	C 	C 	C 	C 	Cr   rU  c                   ^    e Zd Z ej        ej        j        dk    d          d             ZdS )DocTestsr   z)Docstrings are omitted with -OO and abovec                     t          j        t          t           j                  \  }}|                     |d           |                     |d           d S )N)optionflagsr   )doctesttestmodr<   ELLIPSISassertGreaterrF   )rJ   failedtrieds      r   test_doc_testszDocTests.test_doc_tests  sQ      
@PQQQ5!$$$#####r   N)	r7   r8   r9   rQ   skipIfsysflagsoptimizerl  r;   r   r   rc  rc    sQ        X_SY'1,@B B$ $B B$ $ $r   rc  c                       e Zd Zd ZdS )StatisticsErrorTestc                     d}|                      t          t          d                     |                      t          t          j        t
                    |t          j        j        z             d S )NzNExpected StatisticsError to be a ValueError, but got a subclass of %r instead.StatisticsError)r   rY  r<   rD  rt  r-   __base__)rJ   errmsgs     r   test_has_exceptionz&StatisticsErrorTest.test_has_exception  si    + 	 	
,=>>???:5zBB3<<	 	 	 	 	r   N)r7   r8   r9   rw  r;   r   r   rr  rr    s#        	 	 	 	 	r   rr  c                   8    e Zd Zd Zd Zd Zd Zd Zd Zd Z	dS )	ExactRatioTestc                 d    dD ],}|                      t          j        |          |df           -d S )N)ir   r   c   l      Fx:^V r
   )rF   r<   _exact_ratio)rJ   rg   s     r   test_intzExactRatioTest.test_int  sG    , 	A 	AAZ4Q77!Q@@@@	A 	Ar   c                     d}|D ]<}t          |d          }|                     t          j        |          |df           =d S )N)r
   r   &   r   )r   rF   r<   r}  )rJ   r   r   r   s       r   test_fractionzExactRatioTest.test_fraction  sY    $
 	B 	BABAZ4Q77!RAAAA	B 	Br   c                 B   |                      t          j        d          d           |                      t          j        d          d           d t          d          D             }|D ]2}t          j        |          \  }}|                      |||z             3d S )Nr   r
   r         ?)r   r   c                 8    g | ]}t          j        d d          S )r   randomuniformr   r^  s     r   
<listcomp>z-ExactRatioTest.test_float.<locals>.<listcomp>  s$    >>>atS))>>>r   r   )rF   r<   r}  range)rJ   datar   numdens        r   
test_floatzExactRatioTest.test_float  s    077@@@077@@@>>5::>>> 	) 	)A!.q11HCQC((((	) 	)r   c                    t           }t          j        }|                      | |d                    d           |                      | |d                    d           |                      | |d                    d           d S )Nz0.125r  z12.345)i	     z-1.98)ir  )r   r<   r}  rF   )rJ   r   r}  s      r   test_decimalzExactRatioTest.test_decimal  s    !.aajj116:::aakk22K@@@aajj119=====r   c                    t          d          } G d dt                     } G d dt                    }|| fD ]}t           |t          |fD ]} ||          }t          j        |          }|                     ||d f           |                     t          |d                   |           |                     t          j        |d                              d S )NINFc                       e Zd ZdS )(ExactRatioTest.test_inf.<locals>.MyFloatNr7   r8   r9   r;   r   r   MyFloatr            Dr   r  c                       e Zd ZdS )*ExactRatioTest.test_inf.<locals>.MyDecimalNr  r;   r   r   	MyDecimalr    r  r   r  r   )	r   r   r<   r}  rF   r   r   r   r.   )rJ   r  r  r  r!   r   r   ratios           r   r(  zExactRatioTest.test_inf  s   Ell	 	 	 	 	e 	 	 		 	 	 	 	 	 	 	#; 	6 	6C'9= 6 6E#JJ"/22  D	222  eAh777
58 4 455556	6 	6r   c                    t          d          } G d dt                     }| ||          fD ]}t          j        |          }|                     t	          j        |d                              |                     |d         d            |                     t          |d                   t          |                     d S )NNANc                       e Zd ZdS ).ExactRatioTest.test_float_nan.<locals>.MyFloatNr  r;   r   r   r  r    r  r   r  r   r
   )	r   r<   r}  r   r   r   assertIsrF   r   )rJ   r  r  r*  r  s        r   test_float_nanzExactRatioTest.test_float_nan  s    Ell	 	 	 	 	e 	 	 	& 	8 	8C+C00EOODJuQx00111MM%(D)))T%(^^T#YY7777		8 	8r   c                    t          d          }t          d          } G d dt                     }| ||          | ||          fD ]}t          j        |          }|                     t	          |d         |                     |                     |d         d            |                     t          |d                   t          |                     d S )Nr  sNANc                       e Zd ZdS )2ExactRatioTest.test_decimal_nan.<locals>.MyDecimalNr  r;   r   r   r  r    r  r   r  r   r
   )r   r<   r}  r   r   r  rF   r   )rJ   r  r  r  r*  r  s         r   test_decimal_nanzExactRatioTest.test_decimal_nan  s    ennv	 	 	 	 	 	 	 	3yy? 	8 	8C+C00EOOJuQx55666MM%(D)))T%(^^T#YY7777		8 	8r   N)
r7   r8   r9   r~  r  r  r  r(  r  r  r;   r   r   ry  ry    s        A A AB B B) ) )> > >6 6 68 8 8	8 	8 	8 	8 	8r   ry  c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )DecimalToRatioTestc                     t          d          }|                     t          j        |          |d f           |                     t          j        |           | d f           d S )Nr  )r   rF   r<   r}  )rJ   r!   s     r   test_infinityz DecimalToRatioTest.test_infinity  sa    enn055T{CCC0#66#tEEEEEr   c                     t          d          t          d          fD ]R}t          j        |          \  }}|                     t	          ||                     |                     |d            Sd S )Nr  r  )r   r<   r}  r   r   r  )rJ   r*  r  r  s       r   r,  zDecimalToRatioTest.test_nan  su    ENNGFOO4 	% 	%C!.s33HC OOJsC00111MM#t$$$$	% 	%r   c                 Z   t          d          t          d          g}|D ]}t          j        |          \  }}|                     |d           |                     |d           t          j        |           \  }}|                     |d           |                     |d           d S )Nz	9.8765e12z
9.8765e-12r   )r   r<   r}  assertGreaterEqualri  assertLessEqual)rJ   numbersr   r  r  s        r   	test_signzDecimalToRatioTest.test_sign!  s    ;'')>)>? 		' 		'A ".q11HC##C+++sA&&&!.r22HC  a(((sA&&&&		' 		'r   c                 t    t          j        t          d                    }|                     |d           d S )Nz0.1234)ii    r<   r}  r   rF   rJ   ts     r   test_negative_exponentz)DecimalToRatioTest.test_negative_exponent/  s6    #GH$5$566K(((((r   c                 t    t          j        t          d                    }|                     |d           d S )Nz1.234e7)i K r
   r  r  s     r   test_positive_exponentz)DecimalToRatioTest.test_positive_exponent4  s6    #GI$6$677M*****r   c                     t          j        t          d                    }|                     |d           t          j        t          d                    }|                     |d           d S )N1e2)r   r
   z1.47e5)i8> r
   r  r  s     r   test_regression_20536z(DecimalToRatioTest.test_regression_205369  sd     #GENN33H%%%#GH$5$566K(((((r   N)	r7   r8   r9   r  r,  r  r  r  r  r;   r   r   r  r    sq        F F F% % %' ' ') ) )
+ + +
) ) ) ) )r   r  c                        e Zd Zd Zd Zd ZdS )IsFiniteTestc                     dt          dd          dt          d          fD ])}|                     t          j        |                     *d S )Nr   r
   r   rH  5.5)r   r   r   r<   	_isfiniter   s     r   test_finitezIsFiniteTest.test_finiteE  sR    Xa^^S'%..9 	5 	5AOOJ0334444	5 	5r   c                     t          d          t          d          fD ])}|                     t          j        |                     *d S Nr!   r   r   r   r<   r  r   s     r   r  zIsFiniteTest.test_infinityJ  sN    ,,/ 	6 	6AZ1!445555	6 	6r   c                     t          d          t          d          t          d          fD ])}|                     t          j        |                     *d S Nr*  r  r  r  r   s     r   r,  zIsFiniteTest.test_nanO  sV    ,,@ 	6 	6AZ1!445555	6 	6r   N)r7   r8   r9   r  r  r,  r;   r   r   r  r  B  sA        5 5 5
6 6 6
6 6 6 6 6r   r  c                   P    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZdS )
CoerceTestc                    t           t          t          t          fD ]l}|                     t          j        |t                    |            G d d|          }|                     t          j        |t                    |           md S )Nc                       e Zd ZdS )%CoerceTest.test_bool.<locals>.MyClassNr  r;   r   r   MyClassr  p            r   r  )r   r   r   r   r  r<   _coercebool)rJ   Tr  s      r   	test_boolzCoerceTest.test_boolj  s     uh0 	F 	FAMM*,Q55q999"""""!"""MM*,Wd;;WEEEE	F 	Fr   c                     |                      t          j        ||          |           |                      t          j        ||          |           dS )z Assert that type A coerces to B.N)r  r<   r  rJ   ABs      r   assertCoerceTozCoerceTest.assertCoerceTos  sJ    j(A..222j(A..22222r   c                     |                      ||            G d d|          }|                      ||            G d d|          }|                      ||           |                      ||           dS )z6Checks that type A coerces to B, including subclasses.c                       e Zd ZdS )/CoerceTest.check_coerce_to.<locals>.SubclassOfANr  r;   r   r   SubclassOfAr  }  r  r   r  c                       e Zd ZdS )/CoerceTest.check_coerce_to.<locals>.SubclassOfBNr  r;   r   r   SubclassOfBr    r  r   r  N)r  )rJ   r  r  r  r  s        r   check_coerce_tozCoerceTest.check_coerce_tox  s     	Aq!!!"""""!"""K+++"""""!"""A{+++K55555r   c                     |                      t          t          j        ||f           |                      t          t          j        ||f           dS )z=Assert that coercing A to B, or vice versa, raises TypeError.N)r7  	TypeErrorr<   r  r  s      r   assertCoerceRaiseszCoerceTest.assertCoerceRaises  sF    )Z%7!Q@@@)Z%7!Q@@@@@r   c                 l   |                      t          j        ||          |            G d d|          } G d d|          } G d d|          }|||fD ]}|                     ||           |                     ||           |                     ||           |                     ||           dS )z>Check that type T coerces correctly with subclasses of itself.c                       e Zd ZdS )*CoerceTest.check_type_coercions.<locals>.UNr  r;   r   r   Ur    r  r   r  c                       e Zd ZdS )*CoerceTest.check_type_coercions.<locals>.VNr  r;   r   r   Vr    r  r   r  c                       e Zd ZdS )*CoerceTest.check_type_coercions.<locals>.WNr  r;   r   r   Wr    r  r   r  N)r  r<   r  r  r  )rJ   r  r  r  r  typs         r   check_type_coercionszCoerceTest.check_type_coercions  s     	j(A..222q!9 	( 	(C3''''Aq!!!1%%%1%%%%%r   c                     |                      t                     t          t          t          fD ]}|                     t          |           d S rj   )r  r   r   r   r   r  )rJ   r  s     r   r~  zCoerceTest.test_int  sO    !!#&&&8W- 	+ 	+C  c****	+ 	+r   c                 z    |                      t                     |                     t          t                     d S rj   )r  r   r  r   rv   s    r   r  zCoerceTest.test_fraction  s2    !!(+++Xu-----r   c                 :    |                      t                     d S rj   )r  r   rv   s    r   r  zCoerceTest.test_decimal  s    !!'*****r   c                 :    |                      t                     d S rj   )r  r   rv   s    r   r  zCoerceTest.test_float  s    !!%(((((r   c                     t           t          t          d           t          t          fD ]5}t
          t          t          t          fD ]}| 	                    ||           6d S rj   )
strlistr   tupledictr   r   r   r   r  )rJ   bad_type	good_types      r   test_non_numeric_typesz!CoerceTest.test_non_numeric_types  sb    dDJJt< 	= 	=H!5(G< = =	''	8<<<<=	= 	=r   c                     t           t          fD ]F} G d d|          }|                     |t                     |                     |t                     Gd S )Nc                       e Zd ZdS )6CoerceTest.test_incompatible_types.<locals>.MySubclassNr  r;   r   r   
MySubclassr     r  r   r  )r   r   r  r   )rJ   r  r  s      r   test_incompatible_typesz"CoerceTest.test_incompatible_types  si    " 	9 	9A%%%%%Q%%%##Aw///##J8888	9 	9r   N)r7   r8   r9   r  r  r  r  r  r~  r  r  r  r  r  r;   r   r   r  r  U  s        *F F F3 3 3

6 
6 
6A A A
& & & + + +. . .
+ + +) ) )= = =
9 9 9 9 9r   r  c                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
ConvertTestc                     |                      ||           |                     t          |          t          |                     dS )z5Check that x equals y, and has the same type as well.N)rF   r  r   rJ   r   r/   s      r   check_exact_equalzConvertTest.check_exact_equal  s>    Ad1ggtAww'''''r   c                 (   t          j        t          d          t                    }|                     |d            G d dt                    }t          j        t          d          |          }|                     | |d                     d S )Nr   c                       e Zd ZdS )#ConvertTest.test_int.<locals>.MyIntNr  r;   r   r   MyIntr
    r  r   r  r{   )r<   _convertr   r   r  )rJ   r   r  s      r   r~  zConvertTest.test_int  s    c22q"%%%Ce44q%%)),,,,,r   c                 J   t          j        t          dd          t                    }|                     |t          dd                      G d dt                    }t          j        t          dd          |          }|                     | |dd                     d S )N_   r|  c                        e Zd Z fdZ xZS )-ConvertTest.test_fraction.<locals>.MyFractionc                 l    |                      t                                          |                    S rj   	__class__super__truediv__rJ   r+  r  s     r   r  z9ConvertTest.test_fraction.<locals>.MyFraction.__truediv__  '    ~~egg&9&9%&@&@AAAr   r7   r8   r9   r  __classcell__r  s   @r   
MyFractionr    A        B B B B B B B B Br   r  r      )r<   r  r   r  )rJ   r   r  s      r   r  zConvertTest.test_fraction  s    R 0 0(;;q(2r"2"2333	B 	B 	B 	B 	B 	B 	B 	B R 0 0*==q**R"4"455555r   c                 ,   t          j        t          dd          t                    }|                     |d            G d dt                    }t          j        t          dd          |          }|                     | |d                     d S )	Nru   r   g      c                        e Zd Z fdZ xZS )'ConvertTest.test_float.<locals>.MyFloatc                 l    |                      t                                          |                    S rj   r  r  s     r   r  z3ConvertTest.test_float.<locals>.MyFloat.__truediv__  r  r   r  r  s   @r   r  r     r  r   r  r   r   r  )r<   r  r   r   r  )rJ   r   r  s      r   r  zConvertTest.test_float  s    Q77q$'''	B 	B 	B 	B 	Be 	B 	B 	B A88q''%..11111r   c                 F   t          j        t          dd          t                    }|                     |t          d                      G d dt                    }t          j        t          dd          |          }|                     | |d                     d S )	Nr
   (   z0.025c                        e Zd Z fdZ xZS )+ConvertTest.test_decimal.<locals>.MyDecimalc                 l    |                      t                                          |                    S rj   r  r  s     r   r  z7ConvertTest.test_decimal.<locals>.MyDecimal.__truediv__  r  r   r  r  s   @r   r  r%    r  r   r  r   r   z-0.9375)r<   r  r   r   r  )rJ   r   r  s      r   r  zConvertTest.test_decimal  s    B99q''"2"2333	B 	B 	B 	B 	B 	B 	B 	B b 1 19==q))I"6"677777r   c                     t          d          t          d          fD ]B}|| fD ]:}t          j        |t	          |                    }|                     ||           ;Cd S r  )r   r   r<   r  r   r  )rJ   r  r!   r   s       r   r(  zConvertTest.test_inf  sw    %LL'%..1 	/ 	/CcT{ / /'T#YY77&&q#..../	/ 	/r   c                     t          d          t          d          t          d          fD ]G}t          j        |t	          |                    }|                     t          ||                     Hd S r  )r   r   r<   r  r   r   r   )rJ   r*  r   s      r   r,  zConvertTest.test_nan  sk    %LL'%..'&//B 	0 	0C#Cc33AOOJq#..////	0 	0r   c                     |                      t                    5  t          j        d t                     d d d            d S # 1 swxY w Y   d S rj   )r7  r  r<   r  r   rv   s    r   test_invalid_input_typez#ConvertTest.test_invalid_input_type  s    y)) 	- 	-e,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-s   AA
AN)r7   r8   r9   r  r~  r  r  r  r(  r,  r*  r;   r   r   r  r    s        ( ( (
- - -6 6 62 2 28 8 8/ / /0 0 0
- - - - -r   r  c                   $    e Zd ZdZd Zd Zd ZdS )FailNegTestz Test _fail_neg private function.c                     ddt          d          t          d          g}t          t          j        |                    }|                     ||           d S Nr
          @r   r   )r   r   r  r<   	_fail_negrF   )rJ   valuesnews      r   test_pass_throughzFailNegTest.test_pass_through  sP    S(1++wqzz2:'//00%%%%%r   c                     ddt          d          t          d          fD ]@}| g}t          j        |          }|                     t          j        t          |           Ad S r.  )r   r   r<   r0  r7  rt  next)rJ   r   seqits       r   test_negatives_raisez FailNegTest.test_negatives_raise   sk    S(1++wqzz2 	D 	DA2$C%c**Bj8$CCCC	D 	Dr   c                 (   dt          j        dd          z  }	 t          t          j        dg|                     |                     d           n)# t          j        $ r}|j        d         }Y d }~nd }~ww xY w|                     ||           d S )Nzbadness #%d'  i ru   z(expected exception, but it didn't happenr   )	r  randintr5  r<   r0  failrt  r   rF   )rJ   r]   rh   rv  s       r   test_error_msgzFailNegTest.test_error_msg  s    fnUE:::	B%rdC00111 II@AAAA ) 	 	 	VAYFFFFFF	 	%%%%%s   #A A9"A44A9N)r7   r8   r9   r:   r3  r8  r=  r;   r   r   r,  r,    sJ        **& & &D D D	& 	& 	& 	& 	&r   r,  c                   J    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )UnivariateCommonMixinc                 F    |                      t          | j                   d S rj   r7  r  funcrv   s    r   test_no_argsz"UnivariateCommonMixin.test_no_args  s     )TY/////r   c                 |    g dt          g           fD ](}|                     t          j        | j        |           )d S )Nr;   )iterr7  r<   rt  rB  )rJ   emptys     r   test_empty_dataz%UnivariateCommonMixin.test_empty_data  sL    "d2hh' 	L 	LEj8$)UKKKK	L 	Lr   c                     t          t          d                    }|t          |          k    r't          j        |           |t          |          k    '|S )z"Return int data for various tests.r   r  r  sortedr  shufflerJ   r  s     r   prepare_dataz"UnivariateCommonMixin.prepare_data!  sL    E"IIfTll""N4    fTll""r   c                     |                                  }|d d          }|                     |          }|                     ||d           d S )Nzdata has been modified)rM  rB  assertListEqual)rJ   r  savedr^  s       r   test_no_inplace_modificationsz3UnivariateCommonMixin.test_no_inplace_modifications(  sP      "" QQQIIdOOT5*BCCCCCr   c                     g ddz  }|                      |          }t          j        |           |                      |          }|                     ||           d S )N)r
   r   r   r   r   r   r      r   )rB  r  rK  rF   rJ   r  r%   r$   s       r   test_order_doesnt_matterz.UnivariateCommonMixin.test_order_doesnt_matter2  s^     (''+99T??t46*****r   c                 F    G d dt                     } G d dt                    }d }|                                 }|                     |          }t           t          t          |||fD ]6}|                      ||                    }|                     ||           7d S )Nc                       e Zd ZdS )BUnivariateCommonMixin.test_type_of_data_collection.<locals>.MyListNr  r;   r   r   MyListrX  A  r  r   rY  c                       e Zd ZdS )CUnivariateCommonMixin.test_type_of_data_collection.<locals>.MyTupleNr  r;   r   r   MyTupler[  C  r  r   r\  c                     d | D             S )Nc              3      K   | ]}|V  d S rj   r;   )r   objs     r   r   zXUnivariateCommonMixin.test_type_of_data_collection.<locals>.generator.<locals>.<genexpr>F  s"      ((CC((((((r   r;   r  s    r   	generatorzEUnivariateCommonMixin.test_type_of_data_collection.<locals>.generatorE  s    ((4((((r   )r  r  rM  rB  rE  rF   )rJ   rY  r\  ra  r  r%   kindr   s           r   test_type_of_data_collectionz2UnivariateCommonMixin.test_type_of_data_collection?  s    	 	 	 	 	T 	 	 		 	 	 	 	e 	 	 		) 	) 	)  ""99T??5$C 	/ 	/DYYttDzz**FVX....	/ 	/r   c                     t          ddd          }|                     t          |                    }|                     |                     |          |           d S N   r  r   )r  rB  r  rF   rJ   r  r%   s      r   test_range_dataz%UnivariateCommonMixin.test_range_dataM  sP    RQ99T$ZZ((4(33333r   c                     |                      d            |                      d           |                      d           |                      t                                 d S )Nr   g      E@)check_for_type_errorobjectrv   s    r   test_bad_arg_typesz(UnivariateCommonMixin.test_bad_arg_typesS  s^     	!!$'''!!"%%%!!$'''!!&((+++++r   c                 8     | j         t          | j        g|R   d S rj   rA  rL  s     r   rj  z*UnivariateCommonMixin.check_for_type_errorb  s'    )TY6666666r   c                 N    G d dt                     }|                                 }|                     |          }t           |t          t          fD ]Qfd|D             } t          |          |                     |                    }|                     ||           Rd S )Nc                   ,     e Zd Z fdZ fdZeZ xZS )@UnivariateCommonMixin.test_type_of_data_element.<locals>.MyFloatc                 r     t          |           t                                          |                    S rj   r   r  r  r  s     r   r  zLUnivariateCommonMixin.test_type_of_data_element.<locals>.MyFloat.__truediv__j  +    !tDzz%''"5"5e"<"<===r   c                 r     t          |           t                                          |                    S rj   r   r  __add__r  s     r   rv  zHUnivariateCommonMixin.test_type_of_data_element.<locals>.MyFloat.__add__l  )    !tDzz%''//%"8"8999r   )r7   r8   r9   r  rv  __radd__r  r  s   @r   r  rp  i  sJ        > > > > >: : : : :HHHHHr   r  c                 &    g | ]} |          S r;   r;   r   r   rb  s     r   r  zCUnivariateCommonMixin.test_type_of_data_element.<locals>.<listcomp>s  s!    )))DDGG)))r   )r   rM  rB  r   r   r   rF   )rJ   r  rawr%   r  r   rb  s         @r   test_type_of_data_elementz/UnivariateCommonMixin.test_type_of_data_elemente  s    	 	 	 	 	e 	 	 	 !!99S>>GWh7 	/ 	/D))))S)))D#T(^^DIIdOO44FVX....	/ 	/r   N)r7   r8   r9   rC  rG  rM  rQ  rU  rc  rh  rl  rj  r|  r;   r   r   r?  r?    s        0 0 0L L L
  D D D+ + +/ / /4 4 4, , ,7 7 7/ / / / /r   r?  c                       e Zd ZdZd Zd ZdS )UnivariateTypeMixinam  Mixin class for type-conserving functions.

    This mixin class holds test(s) for functions which conserve the type of
    individual data points. E.g. the mean of a list of Fractions should itself
    be a Fraction.

    Not all tests to do with types need go in this class. Only those that
    rely on the function returning the same type as its input data.
    c                 R     G d dt                     }t           t          t          |fS )z4Return the types which are expected to be conserved.c                   b     e Zd Z fdZ fdZ fdZ fdZ fdZ fdZeZ	 fdZ
e
Z xZS )HUnivariateTypeMixin.prepare_types_for_conservation_test.<locals>.MyFloatc                 r     t          |           t                                          |                    S rj   rr  r  s     r   r  zTUnivariateTypeMixin.prepare_types_for_conservation_test.<locals>.MyFloat.__truediv__  rs  r   c                 r     t          |           t                                          |                    S rj   )r   r  __rtruediv__r  s     r   r  zUUnivariateTypeMixin.prepare_types_for_conservation_test.<locals>.MyFloat.__rtruediv__  s+    !tDzz%''"6"6u"="=>>>r   c                 r     t          |           t                                          |                    S rj   )r   r  __sub__r  s     r   r  zPUnivariateTypeMixin.prepare_types_for_conservation_test.<locals>.MyFloat.__sub__  rw  r   c                 r     t          |           t                                          |                    S rj   )r   r  __rsub__r  s     r   r  zQUnivariateTypeMixin.prepare_types_for_conservation_test.<locals>.MyFloat.__rsub__  s+    !tDzz%''"2"25"9"9:::r   c                 r     t          |           t                                          |                    S rj   )r   r  __pow__r  s     r   r  zPUnivariateTypeMixin.prepare_types_for_conservation_test.<locals>.MyFloat.__pow__  rw  r   c                 r     t          |           t                                          |                    S rj   ru  r  s     r   rv  zPUnivariateTypeMixin.prepare_types_for_conservation_test.<locals>.MyFloat.__add__  rw  r   c                 r     t          |           t                                          |                    S rj   )r   r  __mul__r  s     r   r  zPUnivariateTypeMixin.prepare_types_for_conservation_test.<locals>.MyFloat.__mul__  rw  r   )r7   r8   r9   r  r  r  r  r  rv  rx  r  __rmul__r  r  s   @r   r  r    s        > > > > >? ? ? ? ?: : : : :; ; ; ; ;: : : : :: : : : :H: : : : :HHHHHr   r  )r   r   r   )rJ   r  s     r   #prepare_types_for_conservation_testz7UnivariateTypeMixin.prepare_types_for_conservation_test  s=    	 	 	 	 	e 	 	 	" w'22r   c                     |                                  }|                                 D ]Hfd|D             }|                     |          }|                     t	          |                     Id S )Nc                 &    g | ]} |          S r;   r;   rz  s     r   r  z<UnivariateTypeMixin.test_types_conserved.<locals>.<listcomp>  s!    '''Qa'''r   )rM  r  rB  r  r   )rJ   r  r   r   rb  s       @r   test_types_conservedz(UnivariateTypeMixin.test_types_conserved  s       ""<<>> 	. 	.D''''$'''AYYq\\FMM$v,,----	. 	.r   N)r7   r8   r9   r:   r  r  r;   r   r   r~  r~  x  s<         3 3 3*. . . . .r   r~  c                       e Zd Zd ZdS )TestSumCommonc                     d }|| _         d S )Nc                  P    t          j        |  \  }}}t          j        ||          S rj   )r<   _sumr  )r   r  valuer   s       r   simplified_sumz+TestSumCommon.setUp.<locals>.simplified_sum  s'    $/40KAua%eQ///r   )rB  )rJ   r  s     r   setUpzTestSumCommon.setUp  s    	0 	0 	0 #			r   N)r7   r8   r9   r  r;   r   r   r  r    s#        
# # # # #r   r  c                   J    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )TestSumc                 (    t           j        | _        d S rj   )r<   r  rB  rv   s    r   r  zTestSum.setUp      O			r   c                     g dt          g           fD ]@}|                     |                     |          t          t	          d          df           Ad S )Nr;   r   )rE  rF   rB  r   r   rL  s     r   rG  zTestSum.test_empty_data  s\    T"XX& 	E 	EDTYYt__sHQKK.CDDDD	E 	Er   c                     |                      |                     g d          t          t          d          df           d S )N)r
   r   r   irf  r   r
   <   r   )rF   rB  r   r   rv   s    r   	test_intszTestSum.test_ints  sI    #?#?#?@@x||Q/	1 	1 	1 	1 	1r   c                     |                      |                     dgdz            t          t          d          df           d S )NrJ  rf        @)rF   rB  r   r   rv   s    r   test_floatszTestSum.test_floats  sH    D6"9--#3	5 	5 	5 	5 	5r   c                     |                      |                     t          dd          gdz            t          t          dd          df           d S )Nr
   r'    r   )rF   rB  r   rv   s    r   test_fractionszTestSum.test_fractions  sV    HQ$5$5#6s#:;;"HQNNC8	: 	: 	: 	: 	:r   c           
      4   t           } |d           |d           |d           |d           |d           |d           |d           |d          g}|                     |                     |          t           t          d	          d
f           d S )Nr  z5.246z1.702z-0.025z3.974z2.328z4.617z2.843z20.686r   )r   rF   rB  rJ   r   r  s      r   test_decimalszTestSum.test_decimals  s    '

AAgJJ'

AAhKK'

AAgJJ'

AAgJJ 	4!78#4#4a8	: 	: 	: 	: 	:r   c                     d t          d          D             }|                     t          |                     |          d                   t	          j        |          d           d S )Nc                 8    g | ]}t          j        d d          S )r  r'  r  r  s     r   r  z7TestSum.test_compare_with_math_fsum.<locals>.<listcomp>  s$    @@@qtT**@@@r   r'  r
   gؗҬ<r1   )r  r_   r   rB  r   fsumrL  s     r   test_compare_with_math_fsumz#TestSum.test_compare_with_math_fsum  s^     A@E$KK@@@uTYYt__Q%788$)D//uUUUUUr   c                     |                      t          | j        g dd           |                      t          | j        g d           d S )Nr
   r   r   999)r
   r   r   r  rA  rv   s    r   test_strings_failzTestSum.test_strings_fail  sI    )TY			5AAA)TY0@0@0@AAAAAr   c                     |                      t          | j        g dd           |                      t          | j        g d           d S )Nr     999)r
   r   r   r  rA  rv   s    r   test_bytes_failzTestSum.test_bytes_fail  sI    )TY			6BBB)TY0A0A0ABBBBBr   c           	          |                      t          | j        ddt          d          g           |                      t          | j        ddgt          d                     d S )Nr
   r/  )r7  r  rB  r   rv   s    r   test_mixed_sumzTestSum.test_mixed_sum  sW     	)TYC0DEEE)TYC'!**EEEEEr   N)r7   r8   r9   r  rG  r  r  r  r  r  r  r  r  r;   r   r   r  r    s        
$ $ $E E E
1 1 15 5 5: : :: : :V V VB B B
C C C
F F F F Fr   r  c                       e Zd Zd ZdS )SumTortureTestc                    |                      t          j        g ddz            t          t	          d          df           |                      t          j        g ddz            t          t	          d          df           t          j        g ddz            \  }}}|                     |t                     |                      |d           |                     t          |          dd	           d S )
N)r
   }Ô%ITr
   }Ô%Ir:  g     @i@  )r  r
   r
   r  )0.++r
   r  ru   g^,gV瞯<r  )rF   r<   r  r   r   r  r_   )rJ   r  r  counts       r   test_torturezSumTortureTest.test_torture  s    )>)>)>u)DEE'!2!2E:	< 	< 	<)>)>)>u)DEE'!2!2E:	< 	< 	<"(?(?(?(EFF3a&&&uSzz7>>>>>r   N)r7   r8   r9   r  r;   r   r   r  r    s#        	? 	? 	? 	? 	?r   r  c                   D    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )SumSpecialValuesc                    t           t          fD ]t} |d          }t          j        d|dg          d         }|                     t          |          |           |                     t          j        |                     ud S )Nr*  r
   r   )	r   r   r<   r  r  r   r   r   r   )rJ   r   r*  r   s       r   r,  zSumSpecialValues.test_nan  s    W% 	0 	0E%,,C_aa[11!4FMM$v,,...OODJv..////		0 	0r   c                     |                      t          j        |                     |                     t	          |          t	          |                     |                     |dk    |dk               dS )z8Check x is an infinity of the same type and sign as inf.r   N)r   r   r.   r  r   rF   )rJ   r   r!   s      r   check_infinityzSumSpecialValues.check_infinity  s`    
1&&&d1ggtCyy)))Qa(((((r   c                     t          j        dd|dg          d         }|                     ||           t          j        dd|d|dg          d         }|                     ||           d S )Nr
   r   r   r   )r<   r  r  rJ   r!   r   s      r   do_test_infzSumSpecialValues.do_test_inf  sq    !QQ003FC(((!QQQ!788;FC(((((r   c                 ^    t          d          }dD ]}|                     ||z             d S Nr!   r
   ru   )r   r  rJ   r!   r   s      r   test_float_infzSumSpecialValues.test_float_inf  sA    Ell 	' 	'DT#X&&&&	' 	'r   c                 ^    t          d          }dD ]}|                     ||z             d S r  )r   r  r  s      r   test_decimal_infz!SumSpecialValues.test_decimal_inf  sA    enn 	' 	'DT#X&&&&	' 	'r   c                     t          d          }t          j        dd|d| dg          d         }|                     t	          j        |                     d S Nr!   r
   r   r   r   )r   r<   r  r   r   r   r  s      r   test_float_mismatched_infsz+SumSpecialValues.test_float_mismatched_infs  sR    Ell!QQa!899!<
6**+++++r   c                 "   t          d          }dd|d| dg}t          j        t          j                  5  |                     t          j        t          j        |          d                              d d d            d S # 1 swxY w Y   d S r  )	r   decimallocalcontextExtendedContextr   r   r   r<   r  rJ   r!   r  s      r   3test_decimal_extendedcontext_mismatched_infs_to_nanzDSumSpecialValues.test_decimal_extendedcontext_mismatched_infs_to_nan  s    enn1c1sdA&!'"9:: 	B 	BOODJzt'<'<Q'?@@AAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	Bs   A BBBc                     t          d          }dd|d| dg}t          j        t          j                  5  |                     t          j        t          j        |           d d d            d S # 1 swxY w Y   d S r  )r   r  r  BasicContextr7  InvalidOperationr<   r  r  s      r   0test_decimal_basiccontext_mismatched_infs_to_nanzASumSpecialValues.test_decimal_basiccontext_mismatched_infs_to_nan%  s    enn1c1sdA&!'"677 	O 	Og6
NNN	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	Os   ,A00A47A4c                     t          d          }d|dg}|                     t          j        t          j        |           d S )Nr  r
   r   )r   r7  r  r  r<   r  )rJ   r  r  s      r   test_decimal_snan_raisesz)SumSpecialValues.test_decimal_snan_raises,  s;    v4|'2JOTJJJJJr   N)r7   r8   r9   r,  r  r  r  r  r  r  r  r  r;   r   r   r  r    s        0 0 0  ) ) )' ' '
' ' '
, , ,B B BO O OK K K K Kr   r  c                        e Zd Zd Zd Zd ZdS )AverageMixinc                     dddt          dd          t          d          fD ],}|                     |                     |g          |           -d S Nr   g     @E@g  X_yCr}      z0.28r   r   rF   rB  r   s     r   test_single_valuezAverageMixin.test_single_value8  s[    dFHR$4$4gfooF 	0 	0ATYYs^^Q////	0 	0r   c                 F    dddt          dd          t          d          fS )N      @r{    7y!C=   C   z4.9712r   r   rv   s    r   'prepare_values_for_repeated_single_testz4AverageMixin.prepare_values_for_repeated_single_test=  s%    R"b!1!1783D3DEEr   c                     |                                  D ]e}dD ]`}|                     ||          5  |g|z  }|                     |                     |          |           d d d            n# 1 swxY w Y   afd S )Nr   r   r   rf  )r   r  )r  subTestrF   rB  rJ   r   r  r  s       r   test_repeated_single_valuez'AverageMixin.test_repeated_single_value@  s    ==?? 	9 	9A' 9 9\\AU\33 9 93u9D$$TYYt__a8889 9 9 9 9 9 9 9 9 9 9 9 9 9 99	9 	9s   0A..A25A2N)r7   r8   r9   r  r  r  r;   r   r   r  r  5  sD        0 0 0
F F F9 9 9 9 9r   r  c                   \    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZdS )TestMeanc                 (    t           j        | _        d S rj   )r<   meanrB  rv   s    r   r  zTestMean.setUpJ  r  r   c                 \    |                      |                     g d          d           d S )N)r  r
   r   r  r
   rF   rB  rv   s    r   test_torture_pepzTestMean.test_torture_pepM  s1    #8#8#8991=====r   c                     g d}t          j        |           |                     |                     |          d           d S )N)r   r
   r   r   r   r   r   r   r   rS  r   r   r   r   r   r   g     @@r  rK  rF   rB  rL  s     r   r  zTestMean.test_intsQ  sC    ???t4&11111r   c                     g d}t          j        |           |                     |                     |          d           d S )N)g     @1@g     3@      4@g     5@g     5@g     @7@g      9@g     ;@g     6@r  rL  s     r   r  zTestMean.test_floatsW  sC    EEEt4)44444r   c                    t           } |d           |d           |d           |d           |d          g}t          j        |           |                     |                     |           |d                     d S )Nz1.634z2.517z3.912z4.072z5.813z3.5896r   r  rK  rF   rB  r  s      r   r  zTestMean.test_decimals]  s}    '

AAgJJ'

AAgJJ'

Kt4!!H++66666r   c           
      @   t           } |dd           |dd           |dd           |dd           |dd           |dd           |dd          g}t          j        |           |                     |                     |           |d	d
                     d S )Nr
   r   r   r   r   rS  r   r   i  i  r   r  rK  rF   rB  rJ   r   r  s      r   r  zTestMean.test_fractionsd  s    !Q1a!!Aq''11Q77AAaGGQQq!WWaa1ggNt4!!D$--88888r   c                    g d}t           t          fD ]m}dD ]h} |d          |z  }||gz   }|                     |          }|                     t	          j        |                     |                     ||           ind S )Nr
   r   r   r   r   r  r!   )r   r   rB  r   r   r.   rF   )rJ   r{  rb  r   r!   r  r   s          r   r(  zTestMean.test_infk  s    ooG$ 	. 	.D . .d5kk$&cU{4
6 2 2333  ----.	. 	.r   c           
          dddt          d          dddt          d          g}|                     |          }|                     t          j        |                     d S )	Nr   r   rS  r!   r
   r   r   z-inf)r   rB  r   r   r   rJ   r  r   s      r   test_mismatched_infszTestMean.test_mismatched_infsv  sU    1auq!Qf>4
6**+++++r   c                     g d}t           t          fD ]O} |d          }||gz   }|                     |          }|                     t	          j        |                     Pd S )Nr  r*  )r   r   rB  r   r   r   )rJ   r{  rb  r!   r  r   s         r   r,  zTestMean.test_nan|  so    ooG$ 	0 	0D$u++C#;DYYt__FOODJv..////		0 	0r   c                     dg d}|                      |          z   }|                      fd|D                       }|                     ||           d S )Ng    eA	333333@      @g@g@g333333@@g       @g333333 @g"@c                     g | ]}|z   S r;   r;   r   r   cs     r   r  z*TestMean.test_big_data.<locals>.<listcomp>      ...AAaC...r   rB  rF   rJ   r  r%   r   r  s       @r   test_big_datazTestMean.test_big_data  si    <<<99T??Q&.......//*****r   c                     d t          d          D             }|                     |          }|                     |dz            }|                     ||           d S )Nc                 8    g | ]}t          j        d d          S )r{  r   r  r  s     r   r  z.TestMean.test_doubled_data.<locals>.<listcomp>  $    ;;;!r1%%;;;r   r'  r   r  rB  r_   rT  s       r   test_doubled_datazTestMean.test_doubled_data  s[    ;;uT{{;;;99T??46""vx00000r   c                 v    t          d          }|                     t          j        |g          |           d S )N1e4)r   rF   r<   r  r   s     r   test_regression_20561zTestMean.test_regression_20561  s7     ENN!--q11111r   c                    |                      t          j        ddg          d           d}d}dD ]Z}|                      t          j        |g|z            |           |                      t          j        |g|z            |           [d S )Ngg      g       )r   r   r   r  )rF   r<   r  )rJ   bigtinyr   s       r   test_regression_25177zTestMean.test_regression_25177  s     	#%:;= =!	# 	# 	# $ 	> 	>AZ_cU1W55s;;;Z_dVAX66====	> 	>r   N)r7   r8   r9   r  r  r  r  r  r  r(  r  r,  r  r  r  r!  r;   r   r   r  r  I  s        $ $ $> > >2 2 25 5 57 7 79 9 9	. 	. 	., , ,0 0 0+ + +1 1 12 2 2> > > > >r   r  c                   x     e Zd Zd Z fdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Z xZS )TestHarmonicMeanc                 (    t           j        | _        d S rj   )r<   harmonic_meanrB  rv   s    r   r  zTestHarmonicMean.setUp  s    ,			r   c                 r    t                                                      }|                    d           |S )Nr   )r  rM  remove)rJ   r1  r  s     r   rM  zTestHarmonicMean.prepare_data  s/    %%''ar   c                 F    dddt          dd          t          d          fS )Nr  r{   r  r  r  z4.125r  rv   s    r   r  z8TestHarmonicMean.prepare_values_for_repeated_single_test  s%    R"b!1!1773C3CDDr   c                 `    g d}|                      |                     |          d           d S )N)r
   r   r   r   r  rJ   r1  s     r   	test_zerozTestHarmonicMean.test_zero  s3    6**A.....r   c                     t           j        }dgg dfD ]L}|                     |          5  |                     || j        |           d d d            n# 1 swxY w Y   Md S )Nru   )r
   r   r   )r1  )r<   rt  r  r7  rB  )rJ   excr1  s      r   test_negative_errorz$TestHarmonicMean.test_negative_error  s    (tZZZ( 	: 	:FV,, : :!!#ty&999: : : : : : : : : : : : : : :	: 	:s   AA	A	c                    dgg dg dg dfD ]w}|                      |          5  |                     t                    5  |                     |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   xd S )Nz3.14)123)r
   r1  r   4r   )gffffff@r  r  z5.6r`  )r  r7  r  rB  rL  s     r   test_invalid_type_errorz(TestHarmonicMean.test_invalid_type_error  s!    HOO"""	
 	$ 	$D 4(( $ $&&y11 $ $IIdOOO$ $ $ $ $ $ $ $ $ $ $ $ $ $ $$ $ $ $ $ $ $ $ $ $ $ $ $ $ $	$ 	$s5   A:A#A:#A''A:*A'+A::A>	A>	c                     g d}t          j        |           |                     |                     |          d           d S )N)r   r   r   r   r   r   g333333@r  rL  s     r   r  zTestHarmonicMean.test_ints  sC    ###t4%00000r   c                     g d}t          j        |           |                     |                     |          d           |                     |                     g d          d           d S )N)r   rJ  rJ  r   r   rJ  )rJ  r   r   r   r   r  rL  s     r   test_floats_exactz"TestHarmonicMean.test_floats_exact  sl    (((t4#...#8#8#8993?????r   c                     t          dd          D ],}|                     |                     |g          |           -d S )Nr
   r   r  rF   rB  r   s     r   test_singleton_listsz%TestHarmonicMean.test_singleton_lists  sH    q# 	0 	0ATYYs^^Q////	0 	0r   c           
         t           }|                     |                      |d           |d           |d           |d          g           |d                      |d           |d           |d           |d          g}t          j        |           |                     |                     |           |d                      |d           |d           |d	           |d
          g}t          j        |           |                     |                     |           |d          dz             d S )Nr}   r  r  r  z0.10z0.20z1.68z0.32z5.94z2.75i iC )r   rF   rB  r  rK  r  s      r   test_decimals_exactz$TestHarmonicMean.test_decimals_exact  s0   AAbEE11R55!!B%%2#?@@!!B%%HHH&		11V99aaii6;t4!!F))444&		11V99aaii6;t4!!E((5.99999r   c           
      @   t           } |dd           |dd           |dd           |dd           |dd           |dd           |dd          g}t          j        |           |                     |                     |           |d	d
                     d S )Nr
   r   r   r   r   rS  r   r   i|  i  r  r  s      r   r  zTestHarmonicMean.test_fractions  s    !Q1a!!Aq''11Q77AAaGGQQq!WWaa1ggNt4!!E4..99999r   c                 |    dt          d          dg}|                     |                     |          d           d S )Nr/  r!   r   )r   rF   rB  r*  s     r   r(  zTestHarmonicMean.test_inf  s<    uU||S)6**C00000r   c                     dt          d          dg}|                     t          j        |                     |                               d S )Nr/  r*  r   )r   r   r   r   rB  r*  s     r   r,  zTestHarmonicMean.test_nan  sB    uU||S)
499V#4#45566666r   c                     dg d}|                      |          z  }|                      fd|D                       }|                     ||           d S )No   r  c                     g | ]}|z  S r;   r;   r  s     r   r  z>TestHarmonicMean.test_multiply_data_points.<locals>.<listcomp>  r  r   r  r  s       @r   test_multiply_data_pointsz*TestHarmonicMean.test_multiply_data_points  si    <<<99T??1$.......//*****r   c                     d t          d          D             }|                     |          }|                     |dz            }|                     ||           d S )Nc                 8    g | ]}t          j        d d          S )r
   r   r  r  s     r   r  z6TestHarmonicMean.test_doubled_data.<locals>.<listcomp>  s$    :::q!$$:::r   r'  r   r  rT  s       r   r  z"TestHarmonicMean.test_doubled_data  s[    ::eDkk:::99T??46""vx00000r   c           
      t   |                      |                     ddgddg          d           |                      |                     ddgddg          d           |                      |                     t          ddg          t          ddg                    d           |                      |                     t          dd          t          d	d          t          d
d          gg d          |                     t          dd          gdz  t          d	d          gdz  z   t          d
d          gdz  z                        |                      |                     dgd
g          d           |                     t
                    5  |                     g dg d           d d d            n# 1 swxY w Y   |                     t          j                  5  |                     g dddg           d d d            n# 1 swxY w Y   |                     t          j                  5  |                     dgdg           d d d            n# 1 swxY w Y   |                     t          j                  5  |                     ddgddg           d d d            d S # 1 swxY w Y   d S )Nr#  r  r   r  g      L@)weightsr   r   r   r   r   )r   r   r   r  )r
   r;   r   r
   r   rf  )rF   rB  rE  r   r7  r  r<   rt  rv   s    r   test_with_weightsz"TestHarmonicMean.test_with_weights  s   B8aW55t<<<B8,-r7 # 4 459	; 	; 	;4R>>#'B==2 237	9 	9 	9IIxAQ!QH***UUIIxA'!+A'!+,1~~&+, - -	. 	. 	.
 	B4!--r222y)) 	- 	-IIiii,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-z9:: 	) 	)IIiii!Q(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)z9:: 	! 	!IIrdQC   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!z9:: 	( 	(IIr2hA'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(sH   F;;F?F?%HHH6II"IJ--J14J1)r7   r8   r9   r  rM  r  r+  r.  r4  r  r7  r:  r<  r  r(  r,  rC  r  rH  r  r  s   @r   r#  r#    s       - - -    E E E/ / /
: : :
$ 
$ 
$1 1 1@ @ @0 0 0
	: 	: 	:: : :1 1 1
7 7 7
+ + +1 1 1( ( ( ( ( ( (r   r#  c                   H     e Zd Zd Z fdZd Zd Zd Zd Zd Z	d Z
 xZS )	
TestMedianc                 (    t           j        | _        d S rj   r<   medianrB  rv   s    r   r  zTestMedian.setUp$      %			r   c                     t                                                      }t          |          dz  dk    r|                    d           |S )+Overload method from UnivariateCommonMixin.r   r
   )r  rM  ra   rR  )rJ   r  r  s     r   rM  zTestMedian.prepare_data'  sA    ww##%%t99Q;!KKNNNr   c                 `    g d}|                      |                     |          d           d S )Nr
   r   r   r   r   rS  r  r  rL  s     r   test_even_intszTestMedian.test_even_ints.  s3    !!!4#.....r   c                 `    g d}|                      |                     |          d           d S )N)r
   r   r   r   r   rS  r   r   r  rL  s     r   test_odd_intszTestMedian.test_odd_ints4  s3    $$$4!,,,,,r   c                    t           } |dd           |dd           |dd           |dd           |dd          g}t          j        |           |                     |                     |           |dd                     d S )Nr
   r   r   r   r   r   r  r  s      r   test_odd_fractionszTestMedian.test_odd_fractions:  s    !Q1a!!Aq''11Q77AAaGG<t4!!Aq''22222r   c           	      *   t           } |dd           |dd           |dd           |dd           |dd           |dd          g}t          j        |           |                     |                     |           |dd                     d S Nr
   r   r   r   r   r   rS  r  r  s      r   test_even_fractionszTestMedian.test_even_fractionsB      !Q1a!!Aq''11Q77AAaGGQQq!WWEt4!!Aq''22222r   c                    t           } |d           |d           |d           |d           |d          g}t          j        |           |                     |                     |           |d                     d S )N2.53.14.25.75.8r   r  s      r   test_odd_decimalszTestMedian.test_odd_decimalsJ  s}    %!!E((AAeHHaahh%At4!!E((33333r   c                    t           } |d           |d           |d           |d           |d           |d          g}t          j        |           |                     |                     |           |d                     d S )Nz1.2r]  r^  r_  r`  ra  z3.65r   r  s      r   test_even_decimalszTestMedian.test_even_decimalsR  s    %!!E((AAeHHaahh%!!E((Kt4!!F))44444r   )r7   r8   r9   r  rM  rS  rU  rW  rZ  rb  rd  r  r  s   @r   rJ  rJ  "  s        & & &    / / /- - -3 3 33 3 34 4 45 5 5 5 5 5 5r   rJ  c                       e Zd Zd Zd ZdS )TestMedianDataTypec                 (    t           j        | _        d S rj   rL  rv   s    r   r  zTestMedianDataType.setUp]  rN  r   c                     t          t          d                    }|t          |          k    r't          j        |           |t          |          k    '|S )Nr}   rI  rL  s     r   rM  zTestMedianDataType.prepare_data`  sL    E"IIfTll""N4    fTll""r   N)r7   r8   r9   r  rM  r;   r   r   rf  rf  [  s2        & & &    r   rf  c                   &    e Zd Zd Zd Zd Zd ZdS )TestMedianLowc                 (    t           j        | _        d S rj   )r<   
median_lowrB  rv   s    r   r  zTestMedianLow.setUpi  s    )			r   c                 `    g d}|                      |                     |          d           d S )NrR  r   r  rL  s     r   rS  zTestMedianLow.test_even_intsl  3    !!!4!,,,,,r   c           	      *   t           } |dd           |dd           |dd           |dd           |dd           |dd          g}t          j        |           |                     |                     |           |dd                     d S rY  r  r  s      r   rZ  z!TestMedianLow.test_even_fractionsr  r[  r   c                    t           } |d           |d           |d           |d           |d           |d          g}t          j        |           |                     |                     |           |d                     d S Nz1.1z2.2z3.3z4.4r  z6.6r   r  s      r   rd  z TestMedianLow.test_even_decimalsz      %!!E((AAeHHaahh%!!E((Kt4!!E((33333r   Nr7   r8   r9   r  rS  rZ  rd  r;   r   r   rj  rj  h  sP        * * *- - -3 3 34 4 4 4 4r   rj  c                   &    e Zd Zd Zd Zd Zd ZdS )TestMedianHighc                 (    t           j        | _        d S rj   )r<   median_highrB  rv   s    r   r  zTestMedianHigh.setUp  s    *			r   c                 `    g d}|                      |                     |          d           d S )NrR  r   r  rL  s     r   rS  zTestMedianHigh.test_even_ints  rn  r   c           	      *   t           } |dd           |dd           |dd           |dd           |dd           |dd          g}t          j        |           |                     |                     |           |dd                     d S rY  r  r  s      r   rZ  z"TestMedianHigh.test_even_fractions  r[  r   c                    t           } |d           |d           |d           |d           |d           |d          g}t          j        |           |                     |                     |           |d                     d S rq  r   r  s      r   rd  z!TestMedianHigh.test_even_decimals  rr  r   Nrs  r;   r   r   ru  ru    sP        + + +- - -3 3 34 4 4 4 4r   ru  c                   P    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZdS )TestMedianGroupedc                 (    t           j        | _        d S rj   )r<   median_groupedrB  rv   s    r   r  zTestMedianGrouped.setUp  s    -			r   c                 v   g d}|                      |                     |          d           g d}|                      |                     |          d           g d}|                      |                     |d          d           g d}|                     |                     |d	          d
d           d S )N)r   r     r  r  r}   r}   r  )r   r  r  r  r  r  r}   g     +@)r   r   r   r}   rf  rf  rf  rf     r  r  r   g     `3@)r      r  r  r  rf  rf  rf     r  r     r        r   g4@:0yE>r0   rF   rB  r_   rL  s     r   test_odd_number_repeatedz*TestMedianGrouped.test_odd_number_repeated  s    +++4"---+++4&111:::4++V444KKKtyyq11;DIIIIIr   c                 x   g d}|                      |                     |d          dd           g d}|                      |                     |          dd           g d}|                     |                     |          d	           g d
}|                     |                     |          d           d S )N)
r   r   r   r}   rf  rf  rf  r  r  r  r   g*3@r  r  )r   r   r   r   r   r   g["8@)r   r   r   r   r   r   r   r   r   r   rS  rS  r  )
r   r   r   r   r   r   r   r   rS  rS        @)r_   rB  rF   rL  s     r   test_even_number_repeatedz+TestMedianGrouped.test_even_number_repeated  s    666tyyq11;DIII!!!tyy
EEE3334#...---4$/////r   c                     dddt          dd          t          d          fD ]C}dD ]>}|g|z  }|                     |                     |          t	          |                     ?Dd S )N333333@D   g ޗCr   r   z32.9714r  r   r   rF   rB  r   r  s       r   r  z,TestMedianGrouped.test_repeated_single_value  s     r68B#4#4gi6H6HI 	< 	<A' < <s5y  4%((;;;;<	< 	<r   c                     dddt          dd          t          d          fD ]9}|                     |                     |g          t	          |                     :d S r  r  r   s     r   r  z#TestMedianGrouped.test_single_value  sc     dFHR$4$4gfooF 	7 	7ATYYs^^U1XX6666	7 	7r   c                     t           } |dd           |dd           |dd           |dd           |dd          g}t          j        |           |                     |                     |          d           d S )Nr   r   r   r  r{         @r  r  s      r   rW  z$TestMedianGrouped.test_odd_fractions  s    !Q1a!!B((AAb!HHaaAhh?t4#.....r   c           	         t           } |dd           |dd           |dd           |dd           |dd           |dd          g}t          j        |           |                     |                     |          d           d S )Nr   r   r   r  r{         
@r  r  s      r   rZ  z%TestMedianGrouped.test_even_fractions  s    !Q1a!!B((AAb!HHaaAhh"aIt4$/////r   c                     t           } |d           |d           |d           |d           |d          g}t          j        |           |                     |                     |          d           d S )Nr  6.57.58.5g      @r   r  s      r   rb  z#TestMedianGrouped.test_odd_decimals  su    %!!E((AAeHHaahh%At4$/////r   c                     t           } |d           |d           |d           |d           |d           |d          g}t          j        |           |                     |                     |          d            |d           |d           |d           |d           |d           |d          g}t          j        |           |                     |                     |          d           d S )Nr  r  r  r        @      @r   r  s      r   rd  z$TestMedianGrouped.test_even_decimals  s    %!!E((AAeHHaahh%!!E((Kt4#...%!!E((AAeHHaahh%!!E((Kt4#.....r   c                    g d}|                      |                     |d          d           g d}|                     |                     |d          dd           g d}|                      |                     |d	          d
           d S )N)
      @rH  rH  r"  r"  r  r  r  r  rO  rJ  g      @)r  rH  rH  r"  r"  r"  r  r  r  r  rO  g["8@r  r  )   r       r  r  r    r  ,  @  iT  rf  g     p@r  rL  s     r   test_intervalzTestMedianGrouped.test_interval  s    FFF4..666LLLtyyt44jdKKKKKK4,,e44444r   c                 :   g d}|                      t          | j        |           g d}|                      t          | j        |           g d}d}|                      t          | j        ||           g d}d}|                      t          | j        ||           d S )N) r  r  )r   r   r   r  r  r   rA  )rJ   r  intervals      r   test_data_type_errorz&TestMedianGrouped.test_data_type_error  s    ||)TY555)TY555yy)TYh???yy)TYh?????r   N)r7   r8   r9   r  r  r  r  r  rW  rZ  rb  rd  r  r  r;   r   r   r|  r|    s        . . .J J J$0 0 0$< < <7 7 7/ / /0 0 00 0 0/ / /5 5 5@ @ @ @ @r   r|  c                   D    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )TestModec                 (    t           j        | _        d S rj   )r<   moderB  rv   s    r   r  zTestMode.setUp  r  r   c                 
    g dS )rP  )r
   r
   r
   r
   r   r   r   r   r   r   r   r;   rv   s    r   rM  zTestMode.prepare_data  s     1000r   c                 z    t          ddd          }|                     |                     |          d           d S re  r9  rL  s     r   rh  zTestMode.test_range_data   s9    RQ4"-----r   c                     d}|                      |                     |          d           d                                }|                      |                     |          d           d S )Nabcbdbr   zfe fi fo fum fi fifi)rF   rB  r   rL  s     r   test_nominal_datazTestMode.test_nominal_data%  s^    4#...#))++4$/////r   c                     t          t          d                    }t          d          D ]E}||gz   }t          j        |           |                     |                     |          |           Fd S Nr   r  r  r  rK  rF   rB  )rJ   r  rg   r   s       r   test_discrete_datazTestMode.test_discrete_data,  sp    E"IIr 	. 	.As
AN1TYYq\\1----	. 	.r   c                 `    g d}|                      |                     |          d           d S )N)r
   r
   r   r   r   r   r   r   r   rS  rS  rS  rS  r   r   r   r   r   r  rL  s     r   test_bimodal_datazTestMode.test_bimodal_data4  s5    BBB 	4!,,,,,r   c                     t          t          d                    }|                     |                     |          d           d S )Nr   r   )r  r  rF   rB  rL  s     r   test_unique_datazTestMode.test_unique_data;  s9    E"II4!,,,,,r   c                 H    |                      t          | j        d            d S rj   rA  rv   s    r   test_none_datazTestMode.test_none_dataA  s$    
 	)TY55555r   c                     t          j        dd          }|                     |                     |          d           d S )Nr
   r   )r   r   r   )rV   CounterrF   rB  )rJ   r  s     r   test_counter_datazTestMode.test_counter_dataH  sA    
 !q))) 	1s+++++r   N)r7   r8   r9   r  rM  rh  r  r  r  r  r  r  r;   r   r   r  r    s        $ $ $1 1 1
. . .
0 0 0. . .- - -- - -6 6 6, , , , ,r   r  c                       e Zd Zd ZdS )TestMultiModec                     t           j        }|                      |d          dg           |                      |d          g d           |                      |d          g            d S )Naabbbbbbbbccr   aabbbbccddddeeffffgg)r   r   r   r  )r<   	multimoderF   )rJ   r  s     r   test_basicszTestMultiMode.test_basicsU  su    (	>22SE:::#9::OOOLLL2+++++r   N)r7   r8   r9   r  r;   r   r   r  r  S  s#        , , , , ,r   r  c                   &    e Zd Zd Zd Zd Zd ZdS )	TestFMeanc           
         t           j        }t          }t          }g dddf |d           |d           |d          gddf |dd	           |d
d           |dd
          gddfg dddfdd
 |dd
          gddfdt	          g d          ddffD ]Q\  }}} ||          }|                     t          |          t          |           |                     |||           Rd S )Nr  rI        @      @floats3.54.05.25decimalsr   r   r   r
   r   	fractions)TFTTF333333?booleansr  mixed types)r  r  r  iterator)	r<   fmeanr   r   rE  r  r   r   rF   )rJ   r  r   r   r  expected_meanrb  actual_means           r   r  zTestFMean.test_basics^  s-    tX.ahh%!!F)),dJ?a1ggqqAww"a)4=---tZ@1aaAhh}5-"""##T:6* 	? 	?%D-  %++KMM${++UD999[->>>>	? 	?r   c                 "   t           j        }t           j        }|                     |          5   |g            d d d            n# 1 swxY w Y   |                     |          5   |t	          g                      d d d            n# 1 swxY w Y   |                     t
                    5   |d            d d d            n# 1 swxY w Y   |                     t
                    5   |g d           d d d            n# 1 swxY w Y   |                     t
                    5   |             d d d            n# 1 swxY w Y   |                     t
                    5   |g dd           d d d            d S # 1 swxY w Y   d S )Nr   Nrf  r   rf  r  F   )r<   r  rt  r7  rE  r  rJ   r  rt  s      r   test_error_caseszTestFMean.test_error_caseso  s    $4// 	 	E"III	 	 	 	 	 	 	 	 	 	 	 	 	 	 	// 	 	E$r((OOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	E$KKK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	" 	"E...!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"y)) 	 	EGGG	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	$ 	$E,,,###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$sk   AA
A
&BBB0CCC-DDD,EE
E(FFFc                    t           j        }t          d          }t          d          }|                     t	          j         |d|g                    d           |                     t	          j         |||g                    d           |                     t	          j         |d|g                    d           |                     t                    5   ||| g           d d d            d S # 1 swxY w Y   d S NNanInfr   r*  znan and infinityinfinity)	r<   r  r   r   r   r   r.   r7  r-   )rJ   r  NaNr  s       r   test_special_valueszTestFMean.test_special_values  s3    EllEll
55"c#3#344e<<<
55#s#4#4557IJJJ
55"c#3#344jAAAz** 	 	E3+	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   C::C>C>c           	         t           j        }t           j        }|                      |g ddgdz             |g d                     |                      |g dg d           |g d                     |                      |t	          g d          t	          g d                     |g d                     |                     |          5   |g ddd	g           d d d            n# 1 swxY w Y   |                     |          5   |t	          g d          t	          dd	g                     d d d            n# 1 swxY w Y   |                     |          5   |d
dgddg           d d d            n# 1 swxY w Y   |                     |          5   |t	          d
dg          t	          ddg                     d d d            d S # 1 swxY w Y   d S )N)r   r   r   r  rJ  r   )r   r   rf  )rJ  rJ  r   )r   r   rf  rf  r   rf  r  r
   r   r   rf  ru   )r<   r  rt  rF   rE  r7  r  s      r   test_weightszTestFMean.test_weights  s1    $4E"""TFQJ//E"""##	% 	% 	% 	E,,, 2 2 233E"""##	% 	% 	% 	E$|||$$d+=+=+=&>&>??E"""##	% 	% 	% // 	( 	(E,,,A'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(// 	4 	4E$|||$$dAq6ll333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4// 	% 	%E2r(RG$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%// 	1 	1E$Bx..$Aw--000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1sH   C44C8;C8+EEE+FFF(+G  G$'G$N)r7   r8   r9   r  r  r  r  r;   r   r   r  r  \  sP        ? ? ?"$ $ $ 	 	 	1 1 1 1 1r   r  c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	VarianceStdevMixinr*   c                     dddt          dd          t          d          fD ],}|                     |                     |g          d           -d S )Nr   g3@g  %Br   r   z8.392r   r  r   s     r   r  z$VarianceStdevMixin.test_single_value  s]    dFHR$4$4gg6F6FG 	0 	0ATYYs^^Q////	0 	0r   c                     dddt          dd          t          d          fD ]6}dD ]1}|g|z  }|                     |                     |          d           27d S )	Nr  r  g @6<Cr   r   z62.4802)r   r   r   r}   r   r  r  s       r   r  z-VarianceStdevMixin.test_repeated_single_value  sx    r68Aq>>793E3EF 	5 	5A& 5 5s5y  4!44445	5 	5r   c                     dgdz  }|                      |          }|                     |dd           |                     |d           d S )Ng.F7ݚ?r:  rt   gؗҌ<r  r   )rB  r_   r  r  s      r   test_domain_error_regressionz/VarianceStdevMixin.test_domain_error_regression  sY     ""5( 4vs666*****r   c                     g d}|                      |          }dfd|D             }|                     |                      |          |           d S )N)
g{Gz?gRQ?g
ףp=
?gRQ @gp=
ף@gQ	@r  gQ@gGz@gQ@g     j@c                     g | ]}|z   S r;   r;   r   r   shifts     r   r  z6VarianceStdevMixin.test_shift_data.<locals>.<listcomp>      '''aE	'''r   )rB  r_   rJ   r{  r%   r  r  s       @r   test_shift_dataz"VarianceStdevMixin.test_shift_data  sd     KJJ99S>>''''3'''tyy99999r   c                     g d}|                      |          }dfd|D             }|                     |                      |          |           d S )N)
r
   r   r   r   r   r   r   r   r   r   i ʚ;c                     g | ]}|z   S r;   r;   r  s     r   r  z<VarianceStdevMixin.test_shift_data_exact.<locals>.<listcomp>  r  r   r  r  s       @r   test_shift_data_exactz(VarianceStdevMixin.test_shift_data_exact  sa    ///99S>>''''3'''4(33333r   c                     d t          d          D             }|                     |          }|                     |                     t          |                    |           d S )Nc                 8    g | ]}t          j        d d          S )r{  r   r  r  s     r   r  z:VarianceStdevMixin.test_iter_list_same.<locals>.<listcomp>  r  r   r'  )r  rB  rF   rE  rg  s      r   test_iter_list_samez&VarianceStdevMixin.test_iter_list_same  sZ     <;uT{{;;;99T??4::..99999r   N)
r7   r8   r9   r1   r  r  r  r  r  r  r;   r   r   r  r    su         C0 0 0
5 5 5+ + +: : :4 4 4
: 
: 
: 
: 
:r   r  c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )TestPVariancec                 (    t           j        | _        d S rj   )r<   	pvariancerB  rv   s    r   r  zTestPVariance.setUp  s    (			r   c                     t          t          d                    }t          j        |           d}|                     |                     |          |           d S )Nr:  g   P_Ar  rg  s      r   test_exact_uniformz TestPVariance.test_exact_uniform  sP    E%LL!!t$4(33333r   c                 d    g d}d}|                      |                     |          |           d S )Nr   r   r  r   g     6@r  rJ   r  exacts      r   r  zTestPVariance.test_ints  s6    ~~4%00000r   c                    t           } |dd           |dd           |dd           |dd          g} |dd          }|                     |          }|                     ||           |                     |t                      d S )Nr
   r   r   r   r   r   rB  rF   assertIsInstancerJ   r   r  r	  r   s        r   r  zTestPVariance.test_fractions      !Q1a!!Aq''11Q773!Q4'''fh/////r   c                 
   t           } |d           |d           |d           |d          g} |d          }|                     |          }|                     ||           |                     |t                      d S )Nz12.1z12.2z12.5z12.9z0.096875r   rB  rF   r  rJ   r   r  r	  r   s        r   r  zTestPVariance.test_decimals  s    &		11V99aaii6;*4'''fg.....r   c                     g d}d}|                      |          }|                     ||           |                     |t                     d S )N)r   r   r
   gqq?rB  rF   r  r   rJ   r  r	  r   s       r   test_accuracy_bug_20499z%TestPVariance.test_accuracy_bug_20499  Q    yy4'''fe,,,,,r   N)	r7   r8   r9   r  r  r  r  r  r  r;   r   r   r  r    sn        ) ) )4 4 41 1 10 0 0/ / /- - - - -r   r  c                   8    e Zd Zd Zd Zd Zd Zd Zd Zd Z	dS )	TestVariancec                 (    t           j        | _        d S rj   )r<   variancerB  rv   s    r   r  zTestVariance.setUp  s    '			r   c                     dddt          dd          t          d          fD ])}|                     t          j        | j        |g           *d S )Nr   g333338@g (G!=Cr  r  z4.2084r   r   r7  r<   rt  rB  r   s     r   r  zTestVariance.test_single_value  s^    dFHR$4$4gh6G6GH 	J 	JAj8$)aSIIII	J 	Jr   c                 d    g d}d}|                      |                     |          |           d S )Nr  r  r  r  s      r   r  zTestVariance.test_ints  s6    ~~4%00000r   c                    t           } |dd           |dd           |dd           |dd          g} |dd          }|                     |          }|                     ||           |                     |t                      d S )Nr
   r   r   r   r   r  r  s        r   r  zTestVariance.test_fractions   r  r   c                 (   t           } |d           |d           |d           |d          g}d |d          z   |d          z  }|                     |          }|                     ||           |                     |t                      d S )Nr   r   r   r   z9.5r   r  r  s        r   r  zTestVariance.test_decimals)  s    !aaddAAaDD!!A$$'!!E((
11Q444'''fg.....r   c                     d}|                      |                     |          d           |                      |                     |d          d           d S )Nr   r/  r   r/  xbarr   r  rL  s     r   test_center_not_at_meanz$TestVariance.test_center_not_at_mean2  sS    4#...4c22C88888r   c                     g d}d}|                      |          }|                     ||           |                     |t                     d S )N)r   r   r   gUUUUUU?r  r  s       r   r  z$TestVariance.test_accuracy_bug_204997  r  r   N)
r7   r8   r9   r  r  r  r  r  r$  r  r;   r   r   r  r    s        ( ( (J J J
1 1 10 0 0/ / /9 9 9
- - - - -r   r  c                        e Zd Zd Zd Zd ZdS )
TestPStdevc                 (    t           j        | _        d S rj   )r<   pstdevrB  rv   s    r   r  zTestPStdev.setUp@  rN  r   c                     d t          d          D             }t          j        t          j        |                    }|                     |                     |          |           d S )Nc                 8    g | ]}t          j        d d          S )ir  r  r  s     r   r  z7TestPStdev.test_compare_to_variance.<locals>.<listcomp>E  s$    ===AsB''===r   r'  )r  r   sqrtr<   r  rF   rB  rg  s      r   test_compare_to_variancez#TestPStdev.test_compare_to_varianceC  s[    ==t===9Z1$77884(33333r   c                     d}|                      |                     |          d           |                      |                     |d          d           d S )N)r   rS  r   r   rH  r   )mur  r  rL  s     r   r$  z"TestPStdev.test_center_not_at_meanI  sS    4#...4C00#66666r   N)r7   r8   r9   r  r-  r$  r;   r   r   r'  r'  >  sA        & & &4 4 47 7 7 7 7r   r'  c                   0    e Zd Zd Zed             Zd ZdS )TestSqrtHelpersc                    t          j        t          d          t          dd                    D ]\  }}t          j        ||          }|                     |t                     ||z  |z  |k    rB|                     |dz  d           |                     ||dz
  dz  z  |cxk     o||dz   dz  z  k     nc            d S )Nr   r
   r'  r   )		itertoolsproductr  r<   _integer_sqrt_of_frac_rtor  r   rF   r   )rJ   r   mr   s       r   test_integer_sqrt_of_frac_rtoz-TestSqrtHelpers.test_integer_sqrt_of_frac_rtoQ  s    %eCjj%4..AA 		A 		ADAq4Q::A!!!S)))s1uzzQqS!$$$OOAQ
NQ????a!eaZ????@@@@		A 		Ar   c                 0   dt           dt          dt          fd}t          j        }t          d          D ]} |d |d          z            } |d |d          z            dz   }|                     ||	          5  t          ||          }t          j        ||          }| 	                     |||                     d d d            n# 1 swxY w Y   | 
                    t          j        d
d          d           |                     t                    5  t          j        dd           d d d            n# 1 swxY w Y   |                     t                    5  t          j        dd           d d d            n# 1 swxY w Y   |                     t                    5  t          j        dd
           d d d            n# 1 swxY w Y   | 
                    t          j        dd          t          j        dd                     d S )Nr   rootreturnc                 .   | s|dk    S t          j        |t           j                  }t          j        |t           j                   }t          |          }|t          |          z   dz  }|t          |          z   dz  }|dz  | cxk    o|dz  k    nc S )Nrt   r   )r   	nextafterr!   r   )r   r9  r_upr_down	frac_roothalf_way_uphalf_way_downs          r   is_root_correctly_roundedzJTestSqrtHelpers.test_float_sqrt_of_frac.<locals>.is_root_correctly_rounded`  s     #s{" .tx88D N4$(;;F #+4..I%.$%?1$DK'08F3C3C'Cq&HM !A%>>>>kQ.>>>>>>r   i`  r   r  r
   )	numeratordenonimatorr   rt   ru   r   r   )r   r   r  r  	randranger  r  r<   _float_sqrt_of_fracr   rF   r7  r-   ZeroDivisionError)rJ   rB  rE  rg   rC  rD  r   r9  s           r   test_float_sqrt_of_fracz'TestSqrtHelpers.test_float_sqrt_of_frac]  s   	? 	? 	?4 	? 	? 	? 	?$ $	v 	D 	DA&YrYYr]]':;;I(yyy}})<==AK	{KK D D&y+>>(<YTT 9 9!T B BCCCD D D D D D D D D D D D D D D 	71==sCCCz** 	2 	2*2q111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2z** 	2 	2*1b111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 011 	1 	1*1a000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	7B??A_`acdAeAefffffsI   ?ACC	C	EEE&FFF-GGGc                 z   t          d          ddft          d          ddft          d          ddffD ]?\  }}}t          j        t          j                  5  |                     t          j        ||          |           d d d            n# 1 swxY w Y   t          j        t          j                  5 }|xj        dz  c_        t          |          t          |          z  }t          j        |_	        |
                                }d d d            n# 1 swxY w Y   t          j        t          j                  5  |
 }d d d            n# 1 swxY w Y   |                     ||           A|                     t          j        d	d
          d           |                     t          j                  5  t          j        dd
           d d d            n# 1 swxY w Y   |                     t          j                  5  t          j        d
d           d d d            n# 1 swxY w Y   |                     t                    5  t          j        d
d	           d d d            n# 1 swxY w Y   |                     t          j        dd          t          j        dd
                     d S )Nz0.4481904599041192673635338663l   :jt9)4]! l       73Me'z0.7924949131383786609961759598l   Q_Ar,NE*z0.8500554152289934068192208727l   kr"-D9}ZGr   r   r
   rt   ru   r   r   )r   r  r  DefaultContextrF   r<   _decimal_sqrt_of_fracprec
ROUND_05UProundingr,  r7  r  rG  )rJ   r9  rC  denominatorctxhigh_prec_ratiohigh_prec_roottarget_roots           r   test_decimal_sqrt_of_fracz)TestSqrtHelpers.test_decimal_sqrt_of_frac  s    5668VXwx5668VXwx5668VXwx-
 	0 	0(D)[
 %g&<== a a  !A)[!Y!Y[_```a a a a a a a a a a a a a a a %g&<== 8A"))"4"4w{7K7K"K&1!0!5!5!7!7	8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
 %g&<== . .-o. . . . . . . . . . . . . . .T;//// 	9!Q??EEEw788 	4 	4,R333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4w788 	4 	4,Q333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 011 	3 	3,Q222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	9"bAA:CcdeghCiCijjjjjsm   *BB	B	:ADD	"D	EE	E	?G!!G%(G%H--H14H1I44I8;I8N)r7   r8   r9   r7  r   rH  rT  r;   r   r   r1  r1  O  sZ        
A 
A 
A *g *g *gX#k #k #k #k #kr   r1  c                   &    e Zd Zd Zd Zd Zd ZdS )	TestStdevc                 (    t           j        | _        d S rj   )r<   stdevrB  rv   s    r   r  zTestStdev.setUp  s    $			r   c                     dddt          dd          t          d          fD ])}|                     t          j        | j        |g           *d S )NQ   gHzwi@g  f7?+Br   r   z35.719r  r   s     r   r  zTestStdev.test_single_value  s\    ffhq"oowx7H7HI 	J 	JAj8$)aSIIII	J 	Jr   c                     d t          d          D             }t          j        t          j        |                    }|                     |                     |          |           d S )Nc                 8    g | ]}t          j        d d          S )r   r   r  r  s     r   r  z6TestStdev.test_compare_to_variance.<locals>.<listcomp>  r  r   r'  )r  r   r,  r<   r  assertAlmostEqualrB  rg  s      r   r-  z"TestStdev.test_compare_to_variance  s[    ;;uT{{;;;9Z06677tyy99999r   c                 `    d}|                      |                     |d          d           d S )Nr!  r/  r"  r   r  rL  s     r   r$  z!TestStdev.test_center_not_at_mean  s3    4c22C88888r   N)r7   r8   r9   r  r  r-  r$  r;   r   r   rV  rV    sS        % % %J J J
: : :9 9 9 9 9r   rV  c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )TestGeometricMeanc                 R   t           j        }|                      |g d          d           |                      |ddg          d           |                      |dg          d           t          j        d           t          dd	          t          dd
          t          dd          t          ddd          t          ddd          g dd t          d
          D             d t          d          D             d t          d          D             f	D ]}t          j        t          t          |                    t          d          t          |          z  z  } ||          }|                     t          j        |t          |                               d S )N)r|   r  r         B@rI  g      "@g      @g     1@l   ; r
   r   r'  r:  r  r   r{  )r   r{   r  r   x   r   c                 6    g | ]}t          j        d           S )      I@r  expovariater   rg   s     r   r  z1TestGeometricMean.test_basics.<locals>.<listcomp>  s#    @@@a#D))@@@r   c                 8    g | ]}t          j        d d          S )r  r  )r  lognormvariaterh  s     r   r  z1TestGeometricMean.test_basics.<locals>.<listcomp>  s%    HHHa&tS11HHHr     c                 :    g | ]}t          j        d dd          S )rk    i  )r  
triangularrh  s     r   r  z1TestGeometricMean.test_basics.<locals>.<listcomp>  s'    KKK"4t44KKKr   rm  )r<   geometric_meanr]  r  seedr  r   prodr   r   ra   r   iscloser   )rJ   ro  rng
gm_decimalgm_floats        r   r  zTestGeometricMean.test_basics  s   #2~~lll;;TBBB~~sCj993???~~vh77@@@N###aaa  c61%%fc2&&'''@@5<<@@@HH5<<HHHKKeEllKKK
 	G 	GC 3w#4#455'!**s3xx:OPJ%~c**HOODL53D3DEEFFFF	G 	Gr   c           	         t           j        }t          }t          }d}g ddf |d           |d           |d          gdf |dd	           |d
d           |dd
          gdfdd
 |dd
          gdfdt	          g d          dffD ]Q\  }} ||          }|                     t          |          t          |           |                     ||d           Rd S )Ngd@r  r  r  r  r  r  r   r   r   r
   r   r  r  r  )r  r  r  r   places)	r<   ro  r   r   rE  r  r   r   r]  )rJ   ro  r   r   r  r  rb  r  s           r   test_various_input_typesz*TestGeometricMean.test_various_input_types  s   #2x(ahh%!!F)),j9a1ggqqAww"a);71aaAhh/'"""##Z0 
	I 
	IJD$ )...KMM${++UD999"";a"HHHH
	I 
	Ir   c                    t           j        }d} |d|z  d|z  d|z  g          }|                     t          j        |d|z                       |                     t          j        |                     d} |d|z  d|z  d|z  g          }|                     t          j        |d|z                       |                     |d           d S )Ng      p~g      K@g      8@rb  g      prt   )r<   ro  r   r   rr  r   r.   assertNotEqual)rJ   ro  largebig_gmsmallsmall_gms         r   test_big_and_smallz$TestGeometricMean.test_big_and_small  s    #2 te|TE\ JKKVTE\::;;;F++,,, !>4%<te|"LMMXte|<<===Hc*****r   c                 
   t           j        }t           j        }|                     |          5   |g            d d d            n# 1 swxY w Y   |                     |          5   |g d           d d d            n# 1 swxY w Y   |                     |          5   |g d           d d d            n# 1 swxY w Y   |                     |          5   |t	          g                      d d d            n# 1 swxY w Y   |                     t
                    5   |d            d d d            n# 1 swxY w Y   |                     t
                    5   |g d           d d d            n# 1 swxY w Y   |                     t
                    5   |             d d d            n# 1 swxY w Y   |                     t
                    5   |g dd           d d d            d S # 1 swxY w Y   d S )N)r  rt   r  )r  g      r  r  r  r  )r<   ro  rt  r7  rE  r  )rJ   ro  rt  s      r   r  z"TestGeometricMean.test_error_cases  s   #2$4// 	 	N2	 	 	 	 	 	 	 	 	 	 	 	 	 	 	// 	- 	-N+++,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-// 	. 	.N,,,---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.// 	% 	%N488$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%y)) 	! 	!N4   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!y)) 	+ 	+N>>>***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+y)) 	 	N	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	- 	-N<<<,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-s   AA
A
&B  BB B::B>B>C??DD$D<<E E !E;;E?E? F77F;>F;G88G<?G<c                    t           j        }t          d          }t          d          }|                     t	          j         |d|g                    d           |                     t	          j         |||g                    d           |                     t	          j         |d|g                    d           |                     t                    5   ||| g           d d d            d S # 1 swxY w Y   d S r  )	r<   ro  r   r   r   r   r.   r7  r-   )rJ   ro  r  r  s       r   r  z%TestGeometricMean.test_special_values	  s3   #2EllEll
>>2s)#<#<==uEEE
>>3*#=#=>>@RSSS
>>2s)#<#<==zJJJz** 	( 	(NC#;'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(r  c                     t           j        }d}g dg dg dg dg dg}|D ]S}|                     |          5   ||          }|                     ||d	           d d d            n# 1 swxY w Y   Td S )
NgY};t@)r   r   r   r   )r   r   r   r  )r   r   r  r  )r   r  r  r  )r/  r  r  r  )vr   rw  )r<   ro  r  r]  )rJ   ro  r  r1  r  r  s         r   test_mixed_int_and_floatz*TestGeometricMean.test_mixed_int_and_float	  s   #2(LLNN   
  	M 	MA"" M M,nQ//&&{M!&LLLM M M M M M M M M M M M M M M	M 	Ms   $A**A.	1A.	N)	r7   r8   r9   r  ry  r  r  r  r  r;   r   r   r`  r`    sy        G G G,I I I$+ + +- - -(	( 	( 	(M M M M Mr   r`  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )TestQuantilesc                 v   t           j        }g d}t          j        |           dg fddgfdddgfdg d	fd
g dfdg dfdg dfdg dfdg dfdg dff
D ]\  }}|                     | |||                     |                     t           |||                    |dz
             t          t          t          fD ]o |t          |          |          }| 
                    fd|D                        |                     |t          t          |                               pt          |          dk    r!|                      |||          |           t          |          }d|d         z  |d         z
  }d|d         z  |d         z
  }|||gz   }	|                      |||           ||	|d          ||f           d }
t          t          |
|                    } |t          |
|          |          }| 
                    t          d t          ||          D                                  t          dd          D ]\}t          j        t          d           |!          } ||          \  }}}|                     |t          j        |                     ]d S )"N)rc  r     r  i^  r
   r        @o@r         i@      t@r   )      d@r       t@r   )      a@     k@     @r@     u@rS  )      ^@r  r  r       u@r   )      Y@r  g     j@r  g     r@r  g     Xv@r   )	g      V@r  g      g@r  r  r  g     `t@r  g     v@r   )      T@r  r  r        l@r  g     q@r  r  r  g     v@r}   )g      R@g      Z@r  g      e@r  r        n@g     p@r  r  g     t@r  g     @v@g      w@r   c              3   X   K   | ]$}t          t          |          k              V  %d S rj   allr   r   r   datatypes     r   r   z4TestQuantiles.test_specific_cases.<locals>.<genexpr>H	  6      IIQDGGx$7 8 8IIIIIIr   r   ru   r   	inclusiver   methodc                     d| z  dz
  S Nr  g3333J@r;   r   s    r   r   z,TestQuantiles.test_specific_cases.<locals>.fZ	      Qw))r   c              3   F   K   | ]\  }}t          j        ||          V  d S rj   r   rr  r   rh   r   s      r   r   z4TestQuantiles.test_specific_cases.<locals>.<genexpr>^	  2      MMtq!Q 2 2MMMMMMr   r  r   k)r<   	quantilesr  rK  rF   ra   r   r   r   r   r   r  rJ  r  re   r  choicesrM  )rJ   r  r  r   r%   r   sdatalohipadded_datar   expactr  q1q2q3r  s                    @r   test_specific_casesz!TestQuantiles.test_specific_cases/	  s]    (	(((tGL%%%&,,,-3334AAABOOOP       ! 5 5 5 6 )	O )	OKAx Xyy';';';<<<S41!5!5!566A>>>"GX6 H H"3x#6#6!<<<IIII&IIIIII  c(H.E.E)F)FGGGG8}}!!  8q!9!9!98DDD 4LLEU1Xa(BU2Yr*B"b/K	$!$$$	+;???D	  * * *s1h''((C)C4LLA...COOCMMs3}}MMMMMNNNNq" 	: 	:A>%**222D"4JBBR!24!8!89999	: 	:r   c                 
   t           j        }g d}t          j        |           dg fddgfdddgfdg d	fd
g dfdg dfdg dfdg dfdg dfdg dff
D ]U\  }}|                     | |||d                     |                     t           |||d                    |dz
             t          t          t          fD ]p |t          |          |d          }| 
                    fd|D                        |                     |t          t          |                               qd }t          t          ||                    } |t          ||          |d          }| 
                    t          d t          ||          D                                  W|                      |ddgdd          g d           |                      |t          dd          dd          g d           d t          d           D             } ||d!d          }	|                    t!          |                     |                    t#          |                      ||d!"          }|                     ||	           t          dd#          D ]^}
t          j        t          d          |
$          } ||d%          \  }}}|                     |t          j        |                     _d S )&N)r   r  i  i   r
   r        r@r   r        y@r   )     e@r       @@r   )r  r       v@     @rS  )     b@r  r  r       @r   )g     0a@   r  r  g     pw@r  g     P@r   )	g     @`@r  g     g@r  r  r  g     {@r  g     @@r   )g     @_@r  r  r  r  r  r  r  r  r  g     @r}   )r  g     a@r  g     f@r  r  g     q@r  r  r  g      ~@r  g      @g     @r  r  c              3   X   K   | ]$}t          t          |          k              V  %d S rj   r  r  s     r   r   z>TestQuantiles.test_specific_cases_inclusive.<locals>.<genexpr>	  r  r   c                     d| z  dz
  S r  r;   r   s    r   r   z6TestQuantiles.test_specific_cases_inclusive.<locals>.f	  r  r   c              3   F   K   | ]\  }}t          j        ||          V  d S rj   r  r  s      r   r   z>TestQuantiles.test_specific_cases_inclusive.<locals>.<genexpr>	  r  r   r   r   )	      $@r  g      >@g      D@re  g      N@g     Q@r  g     V@r   c                 6    g | ]}t          j        d           S )r:  )r  rE  rh  s     r   r  z?TestQuantiles.test_specific_cases_inclusive.<locals>.<listcomp>	  s#    ===Q ((===r   i      r  r  r  r  )r<   r  r  rK  rF   ra   r   r   r   r   r   r  r  re   r  r'  r   r"   r  rM  )rJ   r  r  r   r%   r   r   r  r  r$   r  r  r  r  r  s                 @r   test_specific_cases_inclusivez+TestQuantiles.test_specific_cases_inclusivee	  s    (	###tGL%%%&,,,-3334>>>?PPPQ ' ' ' ( 5 5 5 6 	O 	OKAx Xyy;'O'O'OPPPS41[!I!I!IJJAPQERRR"GX6 H H"3x#6#6!KPPPIIII&IIIIII  c(H.E.E)F)FGGGG* * *s1h''((C)C4LLAkBBBCOOCMMs3}}MMMMMNNNNAs8r+FFFOOO	Q 	Q 	Q5C==B{KKKOOO	Q 	Q 	Q
 >=%**===42k:::CIICII9TR(((6***q" 	: 	:A>%**222D"4<<<JBBR!24!8!89999	: 	:r   c                     t           j        }t          dd          D ]L}dg|z  }|                      ||          g d           |                      ||d          g d           Md S )Nr   r   r  )r  r  r  r  r  )r<   r  r  rF   )rJ   r  r   r  s       r   test_equal_inputszTestQuantiles.test_equal_inputs	  s    (	q" 	0 	0A6A:DYYt__.@.@.@AAAYYtK@@@...0 0 0 0	0 	0r   c                    t           j        }d}d t          |          D             t          t	                              |k    rG                    t          j        d                     t          t	                              |k    G                                 dD ]P}||z  }| 	                    fd ||          D             t          t          |||                               QdD ]c}||z  ||z  dz   h}fd	 ||          D             }d
 t          ||dd                    D             }|                     ||k               dd S )Nr:  c                 6    g | ]}t          j        d           S )皙?rf  rh  s     r   r  z9TestQuantiles.test_equal_sized_groups.<locals>.<listcomp>	  s#    >>>A"3''>>>r   r  )r
   r   r   r   rf  r  r   r  r  r'  rk  r  r:  c                 :    g | ]}t          j         |          S r;   bisectr   qr  s     r   r  z9TestQuantiles.test_equal_sized_groups.<locals>.<listcomp>	  s%    FFFAtQ''FFFr   r  )
r  r  ;   m      i;  i  is  i  i)&  r
   c                 :    g | ]}t          j         |          S r;   r  r  s     r   r  z9TestQuantiles.test_equal_sized_groups.<locals>.<listcomp>	  s%    HHHa6=q))HHHr   c                     h | ]
\  }}||z
  S r;   r;   )r   pr  s      r   	<setcomp>z8TestQuantiles.test_equal_sized_groups.<locals>.<setcomp>	  s     999tq!QU999r   )r<   r  r  ra   setrR  r  rg  sortrF   r  re   r   )	rJ   r  totalr   
group_sizegroup_sizespossizesr  s	           @r   test_equal_sized_groupsz%TestQuantiles.test_equal_sized_groups	  s   (	>>u>>>#d))nn%%KK*3//000 #d))nn%%		 O 	< 	<A!JFFFF411E1E1EFFFU:uj99::< < < < E 	2 	2A A:uzA~6KHHHH99TQ3G3G3GHHHC99s3ABB'8'8999EOOE[01111		2 	2r   c                    t           j        }t           j        }|                     t                    5   |             d d d            n# 1 swxY w Y   |                     t                    5   |g ddd           d d d            n# 1 swxY w Y   |                     t                    5   |g dd           d d d            n# 1 swxY w Y   |                     |          5   |g dd           d d d            n# 1 swxY w Y   |                     |          5   |g dd           d d d            n# 1 swxY w Y   |                     t                    5   |g dd           d d d            n# 1 swxY w Y   |                     t
                    5   |g dd	           d d d            n# 1 swxY w Y   |                     |          5   |d
gd           d d d            n# 1 swxY w Y   |                     t                    5   |g dd           d d d            d S # 1 swxY w Y   d S )Nr  r  r   r  r   ru   r   Xr  r   )r   Nr  )r<   r  rt  r7  r  r-   )rJ   r  rt  s      r   r  zTestQuantiles.test_error_cases	  s   (	$4y)) 	 	IKKK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	- 	-IlllB!,,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-y)) 	' 	'IlllA&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'// 	) 	)Illla((((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)// 	* 	*Illlb))))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*y)) 	+ 	+Illlc****	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+z** 	0 	0Illl3////	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0// 	! 	!Irda    	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!y)) 	+ 	+Innn****	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s   A

AA/BBB1CCC,DDD(EEE)FF	F	*GG
G
&HHH&II
IN)r7   r8   r9   r  r  r  r  r  r;   r   r   r  r  -	  sa        4: 4: 4:l4: 4: 4:l0 0 02 2 2.+ + + + +r   r  c                       e Zd Zd Zd ZdS )TestBivariateStatisticsc                    g dddgfddgg dffD ]\  }}|                      t          j                  5  t          j        ||           d d d            n# 1 swxY w Y   |                      t          j                  5  t          j        ||           d d d            n# 1 swxY w Y   |                      t          j                  5  t          j        ||           d d d            n# 1 swxY w Y   d S )Nr  r
   r   r7  r<   rt  
covariancecorrelationlinear_regressionr  s      r   test_unequal_size_errorz/TestBivariateStatistics.test_unequal_size_error	  s   YYAVYYY
 		3 		3DAq "":#=>> , ,%a+++, , , , , , , , , , , , , , ,"":#=>> - -&q!,,,- - - - - - - - - - - - - - -"":#=>> 3 3,Q2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3		3 		3s5   AA	A	B##B'	*B'	C//C3	6C3	c                    g g fg ddgfddgg fdgdgfdgddgfddgdgffD ]\  }}|                      t          j                  5  t          j        ||           d d d            n# 1 swxY w Y   |                      t          j                  5  t          j        ||           d d d            n# 1 swxY w Y   |                      t          j                  5  t          j        ||           d d d            n# 1 swxY w Y   d S )Nr
   r   r  r  s      r   test_small_sample_errorz/TestBivariateStatistics.test_small_sample_error	  s   H!QMWbMTA4LTAq7OWqdO
 	3 	3DAq "":#=>> , ,%a+++, , , , , , , , , , , , , , ,"":#=>> - -&q!,,,- - - - - - - - - - - - - - -"":#=>> 3 3,Q2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3	3 	3s6   A''A+	.A+	B33B7	:B7	C??D	D	N)r7   r8   r9   r  r  r;   r   r   r  r  	  s2        
3 
3 
33 3 3 3 3r   r  c                       e Zd Zd Zd ZdS )TestCorrelationAndCovariancec                    g dg ddfg dg ddfg dg ddfg dg ddfg dg dd	ffD ]X\  }}}|                      t          j        ||          |           |                      t          j        ||          |           Yd S )
Nr  r
   ru   r   r{  ru   )r   r   r
   )r
   r   r
   r   )r
   r   r   r   r]  r<   r  r  )rJ   r   r/   r   s       r   test_resultsz)TestCorrelationAndCovariance.test_results	  s    YY			1%YYb)YY			2&YY			1%YY			3'
 	H 	HLAq& "":#9!Q#?#?HHH"":#8A#>#>GGGG	H 	Hr   c                 f   g d}g d}|                      t          j        ||          d           |                      t          j        ||          d           g d}|                      t          j        ||          d           |                      t          j        ||          d           d S )Nr  )r   r  rf  r   r   )r   r  g333333?r
   r   r  r  s      r   test_different_scalesz2TestCorrelationAndCovariance.test_different_scales	  s    IILLz5a;;SAAAz4Q::A>>>LLz5a;;Q???z4Q::C@@@@@r   N)r7   r8   r9   r  r  r;   r   r   r  r  	  s:        	H 	H 	HA A A A Ar   r  c                        e Zd Zd Zd Zd ZdS )TestLinearRegressionc                     g d}g d}|                      t          j                  5  t          j        ||           d d d            d S # 1 swxY w Y   d S )N)r
   r
   r
   r  )r7  r<   rt  r  r  s      r   test_constant_input_errorz.TestLinearRegression.test_constant_input_error

  s    JJJJz9:: 	/ 	/(A...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   AAAc           
          g dg dddfg dg dddfg dg dddfg dg ddd	fg dg d
ddfg dg dddfg dg dddffD ]K\  }}}}t          j        ||          \  }}|                     ||           |                     ||           Ld S )Nr  )r   r   r   r   r
   )r   r   r   r   )r   r  r   r   r   r  ru   )r   r  r   rf  )gffffff@g@r  r   r   )r<   r  r]  )rJ   r   r/   true_intercept
true_slopeslope	intercepts          r   r  z!TestLinearRegression.test_results
  s    YY			1a(YY			1a(YYa0YYb!,YYa,YYb!,YYC01
 	6 	6,Aq.*  *;AqAAE9""9n===""5*5555	6 	6r   c                     g d}g d}t          j        ||d          \  }}|                     |d           |                     |d           d S )N)r   rf  r  r#  )   i  ib  i  T)proportionalgN4@rt   )r<   r  r]  rF   )rJ   r   r/   r  r  s        r   test_proportionalz&TestLinearRegression.test_proportional
  sf       %714PPPyuj111C(((((r   N)r7   r8   r9   r  r  r  r;   r   r   r  r  
  sA        / / /6 6 6) ) ) ) )r   r  c                       e Zd Zd Zd Zd Zd Zd Zd Ze	j
        d             Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )TestNormalDistc                    | j                             dd          }|                     t                    5  t	          |           d d d            n# 1 swxY w Y   |                     t          |j                  d           d S )Nr  r   )_mu_sigma)rZ  
NormalDistr7  r  varsrF   r  	__slots__rJ   nds     r   
test_slotszTestNormalDist.test_slots.
  s    [##C,,y)) 	 	HHH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r|,,.?@@@@@s   AAAc                    | j                             dd          }|                     |j        d           |                     |j        d           |                     |j        d           | j                                         }|                     |j        d           |                     |j        d           |                     |j        d           |                     | j         j                  5  | j                             dd           d d d            n# 1 swxY w Y    G d d| j         j                  } |d	d
          }|                     t          |          |           d S )Nr  r{   i!  r   r
   ic                       e Zd ZdS )GTestNormalDist.test_instantiation_and_attributes.<locals>.NewNormalDistNr  r;   r   r   NewNormalDistr  E
  r  r   r  r  r   )	rZ  r	  rF   r  rX  r  r7  rt  r   )rJ   r  r  nnds       r   !test_instantiation_and_attributesz0TestNormalDist.test_instantiation_and_attributes4
  s   [##C,,#&&&2&&&e,,, [##%%!$$$1%%%d+++ t{:;; 	- 	-K""3,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-	 	 	 	 	DK2 	 	 	mC##cM22222s   6DD"%D"c                 J   | j         j        }g d}|                     |                    |           |dd                     |                     |                    t	          |                     |dd                     |                     |                    t          |                     |dd                     |                     | j         j                  5  |                    g            d d d            n# 1 swxY w Y   |                     | j         j                  5  |                    dg           d d d            n# 1 swxY w Y    G d d|          }|                    |          }|                     t          |          |           d S )N)`   r   Z   r	  n   r|  r   r   c                       e Zd ZdS )BTestNormalDist.test_alternative_constructor.<locals>.NewNormalDistNr  r;   r   r   r  r  Z
  r  r   r  )	rZ  r	  rF   from_samplesr  rE  r7  rt  r   )rJ   r	  r  r  r  s        r   test_alternative_constructorz+TestNormalDist.test_alternative_constructorJ
  s   [+
%%%0066

2q8I8IJJJ00t==zz"a?P?PQQQ00d<<jjQ>O>OPPPt{:;; 	( 	(##B'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(t{:;; 	* 	*##RD)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*	 	 	 	 	J 	 	 	((..cM22222s$   #DD	D	/EEEc                    | j         j        }d\  }} |||          }d}|                    |          }|                     t	          |          |           |                     t          t          t          |                    t          h           | j         	                    |          }| 
                    ||dz  z
  |cxk    o||dz  z   k    nc            d}|                    |d          }|                    |d          }	|                    |d          }
|                    |d          }|                     ||
           |                     |	|           |                     ||	           d S )N)r:  r  r'  r   r   zhappiness and joy)rp  ztrouble and despair)rZ  r	  samplesrF   ra   r  r   r   r   r  r   r{  )rJ   r	  r/  sigmar  r   r  r#  data1data2data3data4s               r   test_sample_generationz%TestNormalDist.test_sample_generation_
  sx   [+
	EJr5!!yy||TA&&&St__--w777{%%U1W<<<<U1W<<<<=== 		!"5	66		!"7	88		!"5	66		!"7	88&&&&&&E5)))))r   c           	         | j         j        } |dd          }|                     |                    d          |                    d                     |                     |                    d          |                    d                     t	          d          D ]D}|                     |                    d|z
            |                    d|z                        Ed}t	          dd          D ]^}|                    ||z             |                    |          z
  |z  }|                     |                    |          |d	
           _ |            }t          g d          D ]b\  }}|                     |                    |dz            |d	
           |                     |                    | dz            |d	
           c |dd          }	|                     | j         j	                  5  |	                    d           d d d            n# 1 swxY w Y   | 
                    |                    t          d                    d           | 
                    |                    t          d                    d           |                     t          j        |                    t          d                                         d S )Nr   r}   r|  r   r  g      P?r  rA  r   rw  )2+ݓ?r&  r&  ggDio?g?gV}b?gQ|?gFx?ggs?g٬\m?g rh?gK7A`?g|гY?gQ?gQI?gsh|??g=yX5?g|a2U0*?gQ?gN@?g/$?g~k	?g]C?gw/?g~:p?g>W[?gMO?gW[?g鷯?g{Gz?gqh?g|a2U?gK7A?gvq-?gjt?gc]F?g\C?gףp=
?g?ga2U0*?gy):?g(y?gN@a?gfc]F?g"lxz,?gOn?g37?gec]?gn?gT?r  r   -Infrt   r  r  )rZ  r	  
assertLesspdfr  r]  cdfrd   r7  rt  rF   r   r   r   r   )
rJ   r	  r  rg   dxr   est_pdfZpxYs
             r   test_pdfzTestNormalDist.test_pdfu
  s   [+
JsBb		155::...c

AEE#JJ///r 	C 	CA""155q>>155q>>BBBBr3 	@ 	@AuuQV}}quuQxx/25G""15588WQ"????JLL  
  
  
   	D 	DEAr ""155U#3#3R"BBB""155!e#4#4b"CCCCJsAt{:;; 	 	EE"III	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	uV}}--s333uU||,,c222
155u#6#67788888s   ?H!!H%(H%c           	      n   | j         j        } |dd          fdt          dd          D             }|                     t	          t          t          |                    t          h           |                     |t          |                     |                     	                    d          d            |            }dD ]_\  }}| 
                    |	                    |          |d	           | 
                    |	                    |           d
|z
  d	           ` |dd          }|                     | j         j                  5  |	                    d           d d d            n# 1 swxY w Y   |                     	                    t          d                    d           |                     	                    t          d                    d
           |                     t          j        	                    t          d                                         d S )Nr   r}   c                 :    g | ]}                     |          S r;   )r*  )r   r   r  s     r   r  z+TestNormalDist.test_cdf.<locals>.<listcomp>
  s#    000Qa000r   r
   r  r   ))rt   r   )r   gqZ ?)r  gE_A?)gQ?gGɫs?)g(\?g؞Y?)gQ?g9#?)gHzG?g&S?)r  gMbX9?)gQ?gT㥛 ?)g?g??)gffffff @g_xZ?)gQ@g#0?)g)\(@gu<f2?)gףp=
@gVe?)gHzG@g9?r   rw  r   r   r  r'  rt   r  r  )rZ  r	  r  rF   r  r   r   r   rJ  r*  r]  r7  rt  r   r   r   )rJ   r	  cdfsr-  zcum_probr/  r  s          @r   test_cdfzTestNormalDist.test_cdf
  s0   [+
JsB0000%3--000St__--w777vd||,,,sT*** JLL 	H 	HKAx ""15588Xa"@@@""155!99cHnQ"GGGGJsAt{:;; 	 	EE"III	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	uV}}--s333uU||,,c222
155u#6#67788888s   E77E;>E;c           	      Z   | j         j        } |dd          }|                     |                    d          |j                    |            }dddd}|                                D ]\  }}t          |d	          D ]j\  }}|d
| z  z  }	|                     |                    |	           |d           d|	z
  }	|                     |                    |	          |d           k|                      |dd                              d          d           d}
t          d|
          D ]C}	|	|
z  }	|                     |	                    |                    |	                    |	           Dt          dd          D ]}d| z  }	|                     |	                    |                    |	                    |	           d|	z
  }	|                     |	                    |                    |	                    |	           t          d          D ]@}|                     |                    |	                    |                    |d           A| 
                    | j         j                  5  |                    d           d d d            n# 1 swxY w Y   | 
                    | j         j                  5  |                    d           d d d            n# 1 swxY w Y   | 
                    | j         j                  5  |                    d           d d d            n# 1 swxY w Y   | 
                    | j         j                  5  |                    d           d d d            n# 1 swxY w Y   | 
                    | j         j                  5   |dd          }|                    d           d d d            n# 1 swxY w Y   |                     t          j        |                    t          d                                         d S )Nr   r}   r   )
rt   gRQ?gS㥛@gS
@gT㥛 @g^I@g rh@g+N@gC@gV-o@)
g rh?g\(\?g~jt@g+@gMbX9@g(\B@gv@g@gSc@gK7A@)
gPn?gS㥛@gQ@gn@g(\@gPn@g@g r@gˡE@glq@)r  rH  r   r
   )startr  r   rw  r   r#  r   g>?g  E@i   3   r/  r  r   rt   r  g?r   r  )rZ  r	  rF   inv_cdfr  itemsrd   r]  r  r*  r7  rt  r   r   r   r   )rJ   r	  iqr-  ppr&   rowr  r   r  r   rh   s               r   test_inv_cdfzTestNormalDist.test_inv_cdf
  s4   [+
 ZR  D))27333
 JLL777	8 8  	B 	BID##Cq111 B BQ4SD>)&&		!}a&BBB!G&&qyy||Qq&AAAA	B 	zz"c22::8DDiPPP q! 	= 	=AFA""266"**Q--#8#8!<<<< q" 	= 	=AA""266"**Q--#8#8!<<<aA""266"**Q--#8#8!<<<<
 s 	G 	GA""2::bffQii#8#8!A"FFFF t{:;; 	 	JJsOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	t{:;; 	 	JJt	 	 	 	 	 	 	 	 	 	 	 	 	 	 	t{:;; 	 	JJsOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	t{:;; 	 	JJsOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	t{:;; 	 	C##BJJsOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 	
199U5\\#:#:;;<<<<<sZ   ;JJ!$J!K))K-0K-L55L9<L9NNN+"OO Oc           
      
   | j                                         }dg fddgfdddgfdg dffD ]U\  }}|                    |	          }|                     t	          d
 t          ||          D                                  Vd S )Nr
   r   rt   r   gǘۿgǘ?r   )g/$rt   g/$?r  c              3   J   K   | ]\  }}t          j        ||d           V  dS )r   )abs_tolNr  r  s      r   r   z0TestNormalDist.test_quantiles.<locals>.<genexpr>  sK        ?  ? $1 !%Q6 B B B  ?  ?  ?  ?  ?  ?r   )rZ  r	  r  r   r  re   )rJ   r-  r   r%   r$   s        r   test_quantileszTestNormalDist.test_quantiles
  s    K""$$GJ&!"&&&'	 	@ 	@KAx [[1[%%FOOC  ?  ?(+Hf(=(= ?  ?  ? ? ? @ @ @ @	@ 	@r   c                    | j         j        } |dd           |dd          df |dd           |dd          dffD ]\\  }}}|                     |                    |          |d           |                     |                    |          |d           ]dd	d
d} |dd           |dd          f |dd           |dd          f |dd           |dd          f |dd           |dd          f |dd           |dd          f |dd           |dd          f |dd           |dd          f |dd           |dd          f |dd           |dd          f |dd           |dd          f |dd           |dd          f |dd           |dd          f |dd           |dd          f |dd           |dd          ffD ]o\  }}|                     |                    |           |||          d	           |                     |                    |           |||          d	           p |            }|                     t
                    5  |                                 d d d            n# 1 swxY w Y   |                     t
                    5  |                    ||           d d d            n# 1 swxY w Y   |                     t
                    5  |                    d            d d d            n# 1 swxY w Y   |                     | j         j                  5  |                     |dd                     d d d            n# 1 swxY w Y   |                     | j         j                  5   |dd                              |           d d d            d S # 1 swxY w Y   d S )Nrt   r/  r   gɎ@?gM-[닄?r   rw  i    r   )stepsr4  c                   t           j        }| j        |j        z   dz  }|t          | j        |j                  z  }||z
  d|z  |z  fdt          |          D             }t          t          | j        |                    }t          t          |j        |                    }	t           ||           ||	                    }
 |t          t          ||	                    |
z  S )z0Numerical integration cross-check for overlap() r/  c                      g | ]
}|z  z   S r;   r;   )r   rg   r+  r8  s     r   r  zHTestNormalDist.test_overlap.<locals>.overlap_numeric.<locals>.<listcomp>  s!    888aUQrT\888r   )
r   r  r  r"   rX  r  r  r   r)  r   )r  r/  rE  r4  r  centerwidthx_arrxpypr  r+  r8  s              @@r   overlap_numericz4TestNormalDist.test_overlap.<locals>.overlap_numeric  s    9Dfqvo,FAGQW---EUNEuu$B888885<<888Ec!%''((Bc!%''((BR$$r((++E4CR(())E11r   r  A   r  r   r}   r  r  ir      r   r  gjt?g~jth?gjt?ga2U0*3?gMbX?r
   r   )rZ  r	  r]  overlapr7  r  rt  )rJ   r	  X1X2published_resultrM  r  s          r   test_overlapzTestNormalDist.test_overlap  s   [+
 C%%zz#s';';WEC%%zz#s';';WE) 	O 	O$B$ ""2::b>>3CA"NNN""2::b>>3CA"NNNN ,1A 	2 	2 	2 	2 	2 C%%zz#s';';<C%%zz#s';';<C%%zz#s';';<B""JJr3$7$78C$$jjb&9&9:D"%%zz#r':':;D"%%zz$';';<C$$jjb&9&9:C$$jjb&9&9:C$$jjb&9&9:C$$jjb&9&9:E5))::eU+C+CDE5))::eV+D+DEE5))::eU+C+CD) 	V 	VFB, ""2::b>>??2r3J3JST"UUU""2::b>>??2r3J3JST"UUUU JLLy)) 	 	IIKKK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	IIaOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	IIdOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	t{:;; 	( 	(IIjjA&&'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(t{:;; 	( 	(Jq!$$Q'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(sZ   ;JJ #J K$$K(+K(	L++L/2L/ NNN+ OOOc                    | j         j        } |dd          }|                     |                    d          d           |                     |                    d          d           |                     |                    d          d           |                     t
                    5  |                                 d d d            n# 1 swxY w Y   |                     t
                    5  |                    dd           d d d            n# 1 swxY w Y   |                     t
                    5  |                    d            d d d            n# 1 swxY w Y   |                     | j         j                  5   |dd	                              d           d d d            d S # 1 swxY w Y   d S )
Nr   r}      gffffff@:   gffffffrt   r
   r   )rZ  r	  rF   zscorer7  r  rt  )rJ   r	  r  s      r   test_zscorezTestNormalDist.test_zscoreG  s   [+
JsB#,,,"t,,,#,,,y)) 	 	HHJJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	HHQNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	HHTNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	t{:;; 	) 	)Jq!##C(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)sH   .CCC4DDD<EE"%E" F55F9<F9c                 J   | j                             dd          }|                     |j        d           |                     |j        d           |                     |j        d           |                     |j        d           |                     |j        d           d S )Nr   r}      )rZ  r	  rF   r  rM  r  rX  r  )rJ   r  s     r   test_propertieszTestNormalDist.test_propertiesV  s    K""3++%%%3'''%%%"%%%S)))))r   c                     | j         j        } |dd          } |dd          }|                     ||z    |dd                     |                     ||z
   |dd                     d S )Nr   r   r#  r      r  r  )rZ  r	  rF   rJ   r	  r  r/  s       r   'test_same_type_addition_and_subtractionz6TestNormalDist.test_same_type_addition_and_subtraction^  s    [+
JsBJr1Q

3 3 3444Q

2r 2 233333r   c                    | j         j        } |dd          }d}|                     |
  |dd                     |                     |  |dd                     |                     ||z    |dd                     |                     ||z    |dd                     |                     ||z
   |dd                     |                     ||z
   |dd                     |                     ||z   |dd	                     |                     ||z   |dd	                     |                     ||z   |dd
                     |                     t                    5  ||z   d d d            d S # 1 swxY w Y   d S )Nr   r}   r   r  r  r  ir'  rO  r   )rZ  r	  rF   r7  r  )rJ   r	  r  r/   s       r   test_translation_and_scalingz+TestNormalDist.test_translation_and_scalinge  s   [+
JsB!ZZR00111!ZZb11222Q

3 3 3444Q

3 3 3444Q

2r 2 2333Q

3 3 3444Q

4 5 5666Q

4 5 5666Q

2s 3 3444y)) 	 	EE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   ,E??FFc                    | j         j        } |dd          }|
 }|                     ||           |                     |j        |j                   |                     |j        |j                   | }|                     ||           |                     |j        |j                    |                     |j        |j                   d S )Nr   r   )rZ  r	  assertIsNotrF   r  rX  r_  s       r   test_unary_operationsz$TestNormalDist.test_unary_operationsu  s    [+
JsBBA(((!'***BA!&)))!'*****r   c                 d   | j         j        } |            } |dd          } |            } |dd          } |dd          } |dd          }|                     ||           |                     ||           |                     ||           |                     ||           |                     ||            G d d          } |            }	|                     |                    |	          t
                     |                     ||	k    d           |                     |	|k    d            G d d|          }
 |
d	d
d          } |d	d
          }|                     ||            G d d          } |d	d
          } |d	d
          }|                     ||           d S )Nr   r   r   c                       e Zd Zd ZdS )'TestNormalDist.test_equality.<locals>.Ac                     dS r  r;   )rJ   r+  s     r   __eq__z.TestNormalDist.test_equality.<locals>.A.__eq__  s    rr   N)r7   r8   r9   rj  r;   r   r   r  rh    s#            r   r  r   c                        e Zd Z fdZ xZS )5TestNormalDist.test_equality.<locals>.SizedNormalDistc                 Z    t                                          ||           || _        d S rj   )r  __init__r   )rJ   r/  r  r   r  s       r   rn  z>TestNormalDist.test_equality.<locals>.SizedNormalDist.__init__  s(      U+++r   )r7   r8   r9   rn  r  r  s   @r   SizedNormalDistrl    s8                r   ro  r   r}   9   c                       e Zd Zd ZdS )3TestNormalDist.test_equality.<locals>.LognormalDistc                 "    || _         || _        d S rj   )r/  r  )rJ   r/  r  s      r   rn  z<TestNormalDist.test_equality.<locals>.LognormalDist.__init__  s    "


r   N)r7   r8   r9   rn  r;   r   r   LognormalDistrr    s#        # # # # #r   rt  )rZ  r	  r{  rF   rj  NotImplemented)rJ   r	  nd1nd2nd3nd4nd5nd6r  r   ro  srt  lndr  s                  r   test_equalityzTestNormalDist.test_equality  s+   [+
jlljAjlljAjAjAC%%%c"""c"""C%%%C%%%	 	 	 	 	 	 	 	 ACCA7772&&&c2&&&	 	 	 	 	j 	 	 	 OCR((jb!!C   
	# 	# 	# 	# 	# 	# 	# 	# mC$$ZR  B$$$$$r   c                     | j                             dd          }t          j        |          }|                     ||           t          j        |          }|                     ||           d S )N     B@     @)rZ  r	  copyrF   deepcopy)rJ   r  rv  rw  s       r   	test_copyzTestNormalDist.test_copy  sg    [##D%00immS!!!mBS!!!!!r   c                 R   | j                             dd          }t          t          j        dz             D ]n}|                     |          5  t          j        t          j        ||                    }|                     ||           d d d            n# 1 swxY w Y   od S )Nr  r  r
   )proto)protocol)	rZ  r	  r  pickleHIGHEST_PROTOCOLr  loadsdumpsrF   )rJ   r  r  pickleds       r   test_picklezTestNormalDist.test_pickle  s    [##D%0062Q677 	. 	.EE** . . ,v|B'G'G'GHH  W---. . . . . . . . . . . . . . .	. 	.s   ?BB	"B	c                     | j         j        } |dd           |dd           |dd           |dd           |dd          h}|                     t          |          d           d S )Nr   r}   r  g      .@r   r  r   )rZ  r	  rF   ra   )rJ   NDr|  s      r   test_hashabilityzTestNormalDist.test_hashability  sp    [#RR[[""UD//22c2;;2r

BBsBKKPQ#####r   c                     | j                             dd          }|                     t          |          d           d S )Nr  r  z NormalDist(mu=37.5, sigma=5.625))rZ  r	  rF   reprr  s     r   	test_reprzTestNormalDist.test_repr  s<    [##D%00b#EFFFFFr   N)r7   r8   r9   r  r  r  r$  r0  r6  r   skip_if_pgo_taskr?  rC  rT  rY  r\  r`  rb  re  r~  r  r  r  r  r;   r   r   r  r  %
  sP       A A A3 3 3,3 3 3** * *,%9 %9 %9N9 9 9< >= >= >=@@ @ @=( =( =(~) ) )* * *4 4 4   
+ 
+ 
+*% *% *%X" " ". . .$ $ $
G G G G Gr   r  c                       e Zd ZeZd Zd ZdS )TestNormalDistPythonc                 .    | j         t          j        d<   d S rD   rZ  rn  modulesrv   s    r   r  zTestNormalDistPython.setUp      $(KL!!!r   c                 .    t           t          j        d<   d S rD   r<   rn  r  rv   s    r   tearDownzTestNormalDistPython.tearDown      $.L!!!r   N)r7   r8   r9   rH   rZ  r  r  r;   r   r   r  r    s7        F0 0 0/ / / / /r   r  rM   c                       e Zd ZeZd Zd ZdS )TestNormalDistCc                 .    | j         t          j        d<   d S rD   r  rv   s    r   r  zTestNormalDistC.setUp  r  r   c                 .    t           t          j        d<   d S rD   r  rv   s    r   r  zTestNormalDistC.tearDown  r  r   N)r7   r8   r9   rO   rZ  r  r  r;   r   r   r  r    s7        F0 0 0/ / / / /r   r  c                 R    |                     t          j                               |S )z&Used for doctest/unittest integration.)addTestsrf  DocTestSuite)loadertestsignores      r   
load_testsr    s"    	NN7'))***Lr   __main__)r*   r+   )Ur:   r  rV   collections.abcr  r  rf  r3  r   r  r  rn  rQ   testr   test.supportr   r   r   r  r   r<   r   r   r)   r4   r6   import_fresh_modulerH   rO   rE  rA   rT   rr   ry   r   r   r   r%  r4  r<  rU  rc  rr  ry  r  r  r  r  r,  r?  r~  r  r  r  r  r  r  r#  rJ  rf  rj  ru  r|  r  r  r  r  r  r  r'  r1  rV  r`  r  r  r  r  r  r  rR   r  r  r7   mainr;   r   r   <module>r     s   
                    



        9 9 9 9 9 9 9 9                
  3 3 3>   2) 2) 2) 2)t$	 $	 $	 $	 $	 $	 $	 $	V 21,;H/K K K0}08EH H H
U 
U 
U 
U 
U(# 
U 
U 
UXF XF XF XF XFh' XF XF XF~) ) ) ) )x  ) ) );J ;J ;J ;J ;Jh/ ;J ;J ;J|=B =B =B =B =B8, =B =B =B@, , , , ,X. , , ,>tE tE tE tE tEX. tE tE tEnK K K K Kh/ K K K8	G 	G 	G 	G 	GH- 	G 	G 	G"% % % % %(+ % % %ZC C C C C(# C C C,$ $ $ $ $x  $ $ $
 
 
 
 
(+ 
 
 
=8 =8 =8 =8 =8X& =8 =8 =8@1) 1) 1) 1) 1)* 1) 1) 1)h6 6 6 6 68$ 6 6 6&a9 a9 a9 a9 a9" a9 a9 a9H;- ;- ;- ;- ;-(# ;- ;- ;-|& & & & &(# & & &<`/ `/ `/ `/ `/ `/ `/ `/F'. '. '. '. '. '. '. '.T	# 	# 	# 	# 	#)+> 	# 	# 	#7F 7F 7F 7F 7Fo 7F 7F 7Ft
? 
? 
? 
? 
?_ 
? 
? 
?;K ;K ;K ;K ;K ;K ;K ;K@9 9 9 9 9( 9 9 9(]> ]> ]> ]> ]>.A ]> ]> ]>@v( v( v( v( v(6I v( v( v(r65 65 65 65 65, 65 65 65r
 
 
 
 
*= 
 
 
4 4 4 4 4J 3 4 4 464 4 4 4 4Z!4 4 4 46u@ u@ u@ u@ u@
 u@ u@ u@p:, :, :, :, :,.A :, :, :,z, , , , ,H% , , ,A1 A1 A1 A1 A1! A1 A1 A1L?: ?: ?: ?: ?:. ?: ?: ?:D)- )- )- )- )-&9L )- )- )-X,- ,- ,- ,- ,-%8K ,- ,- ,-\7 7 7 7 7#_ 7 7 7"^k ^k ^k ^k ^kh' ^k ^k ^kB9 9 9 9 9"O 9 9 9(fM fM fM fM fM) fM fM fMRa+ a+ a+ a+ a+H% a+ a+ a+H3 3 3 3 3h/ 3 3 3>A A A A A8#4 A A A0) ) ) ) )8, ) ) ):]G ]G ]G ]G ]G ]G ]G ]GF/ / / / /8,n / / / \#9::/ / / / /h' / / ;:/   zHMOOOOO r   