
    (phO                       S r SSKrSSKrSSKrSSKJr  SSKJr  SSKJ	s  J
r  SSKrSSKrSSKJrJrJrJrJrJrJrJrJr  SSKrSSKJr  SSKJs  Jr  SSK
JrJ r J!r!J"r"  SSK
r#SSK$J%r%  SSK&J%s  J'r'  SSK(J%s  J)r*  SSK+J,r,  SS	K-J.r.  SS
K/J0r0  SSK1J2r2  SSK3J4r4  SSK5J6r6J7r7J8r8J9r9J:r:J;r;  SSK<J=r=J>r>J?r?J@r@JArAJBrBJCrC  SSKDJErE  SSKFJGrGJHrH  SSKIJJrJJKrKJLrLJMrMJNrNJOrO  SSKPJQrQJRrR  \R                  R                  rT \" / SQ\U5      rV\" / SQ\U5      rW\" / SQ\U5      rX\" / SQ\U5      rY\" / SQ\U5      rZ\" / SQ\U5      r[\" / SQ\U5      r\\G\T" SSS9\T" SSS9\R                  R                  S 5       " S! S"5      5       5       5       5       r^ " S# S$5      r_\G\R                  R                  S 5      \T" S%S&9 " S' S(5      5       5       5       r` " S) S*5      ra " S+ S,5      rb " S- S.5      rcS/ rdS0 reS1 rfS2 rg " S3 S45      rhS5 riS6 rjS7 rkS8 rl " S9 S:5      rm " S; S<5      rnS= roS> rpS? rq " S@ SA5      rr " SB SC5      rs\G " SD SE5      5       rt\G\R                  R                  S 5      \T" SSFS9 " SG SH5      5       5       5       ru " SI SJ5      rvSK rw " SL SM5      rx " SN SO5      ry " SP SQ5      rz " SR SS\z5      r{ " ST SU\z5      r|\R                  R                  SV 5       r\R                  R                  S%SWSX9\R                  R                  S 5      \G " SY SZ5      5       5       5       r " S[ S\5      r\" S]/ S^Q5      r\" / S_QSSSS`SaS`\#GR                  " Sb5      -  Sc\#GR                  " Sd5      -  -   -  SaSe\#GR                  " Sf5      -  Se\#GR                  " Sg5      -  -   -  ShS^9\" / S_Q/ SiQSSSjSaS`\#GR                  " Sf5      -  Se\#GR                  " Sb5      -  -   Se\#GR                  " Sk5      -  -   -  SaSa\#GR                  " Sb5      -  Sl\#GR                  " Sf5      -  -   Sa\#GR                  " Sm5      -  -   -  SnS^9\" / S_QSeSSS`SaS`\#GR                  " Sb5      -  Sc\#GR                  " Sd5      -  -   -  SaSe\#GR                  " Sf5      -  Se\#GR                  " Sg5      -  -   -  ShS^9\" / SoQ/ SoQSSSSSSS^9/r\" / SSSSSSSS^9\" \#R>                  " / / / /5      GR
                  SSS/ SpQ/ SpQ/ SpQ/ SpQS^9\" \#R>                  " / / / /5      SSS/ / / / S^9/r\G " Sq Sr5      5       r\G " Ss St5      5       r\H " Su Sv5      5       rSw r " Sx Sy5      r " Sz S{5      r " S| S}5      rS~ rS rS r\R                  GR#                  S\#GR$                  " S5      S4\#GR$                  " S5      S4/5      S 5       rS r\R                  GR#                  S/ SQ5      S 5       r\R                  GR#                  S\%GR,                  \#R@                  " S5      S44\%GR.                  \#R@                  " S5      \#R@                  " S5      44/5      S 5       rSSS.S jjr\G\R                  R                  S%SWSX9\R                  R                  S 5      S 5       5       5       rS rS r\R                  GR;                  S5       " S S5      5       r\R                  GR;                  S5       " S S5      5       r " S S5      r\G\R                  R                  S%SWSX9\R                  R                  S 5       " S S5      5       5       5       rS r\G\R                  R                  S%SWSX9\R                  R                  S 5      S 5       5       5       r\G\R                  R                  S%SWSX9\R                  R                  S 5      S 5       5       5       rS r\GS 5       r\T" SSS9\R                  R                  S 5      \G\R                  GR#                  S\#GR$                  " S5      S4\#GR$                  " S5      S4/5      S 5       5       5       5       r\GS 5       r\GS 5       r\G\R                  R                  S%SS9\R                  R                  S 5      S 5       5       5       r\G\R                  R                  S%SWSX9\R                  R                  S 5      S 5       5       5       r\G\R                  R                  S%SWSX9\R                  R                  S 5      S 5       5       5       rS r\R                  GR\                  \R                  R                  S%SWSX9\R                  R                  S 5      \GS 5       5       5       5       r\R                  R                  S%SS9\R                  R                  S 5      \GS 5       5       5       r\R                  R                  S%SWSX9\R                  R                  S 5      \GS 5       5       5       r " S S5      r\G " S S5      5       r " S S\5      r " S S\5      r " S S\5      r " S S5      r\G " S S5      5       r " S S5      rS rS rSSSSS.S jrS rS rS r\G " S S5      5       r\G " S S5      5       r\G " S S5      5       r " S S5      rS rS rS r " S S5      r " S S5      r " S S5      r " S S5      r " S S5      r\T" S%SS/SS9\R                  R                  S 5      \G " S S5      5       5       5       r " S S5      r " S S5      r " S S5      r " S S5      r " S S5      r " S S5      r " S S5      r\#GR                  GR                  S5      r\GR                  S5      r\GR                  S5      r\R                  GR#                  S\%GR                  \44\%GR                  \\%GR                  GR                  44\%GR                  \\44\%GR                  \\44/5      S 5       r " S S5      r " S S5      r\G " S S5      5       r\G\R                  R                  S 5      \T" SSS9 " S S5      5       5       5       r\GS 5       r\R                  R                  SSS9\R                  R                  S 5      \GS 5       5       5       rg(   zTest functions for stats module

WRITTEN BY LOUIS LUANGKESORN <lluang@yahoo.com> FOR THE STATS MODULE
BASED ON WILKINSON'S STATISTICS QUIZ
https://www.stanford.edu/~clint/bench/wilk.txt

Additional tests by a host of SciPy developers.
    N)
namedtuple)product)	assert_assert_equalassert_almost_equalassert_array_almost_equalassert_array_equalassert_approx_equalassert_allclosesuppress_warningsassert_array_less)raises)arrayarangefloat32power)kolmogn)FuncData)binom)optimize   )check_named_results)_broadcast_concatenateSmallSampleWarningtoo_small_nd_omittoo_small_nd_not_omittoo_small_1d_omittoo_small_1d_not_omit)_permutation_distribution_t_chk_asarray_momentLinregressResult_xp_mean_xp_var_SimpleChi2)	AxisError)array_api_compatibleskip_xp_invalid_arg)array_namespacexp_copyis_numpyis_torchxp_sizeSCIPY_ARRAY_API)xp_assert_closexp_assert_equal)	r                        	   )	r   r   r   r   r   r   r   r   r   )	iiiiiiiii)	g~?g<?gEk?g?ge(?gq?g?g8C?gG?)	g   mBg   }Bg  yӅBg   Bg  @0Bg  yӕBg  BwBg   Bg   ^B)	-q=g-=gAfc=g-=gdy=gAfc=gYLɞ=g-=gSSʣ=)	      ?      ?      @      @      @      @      @      @      !@	jax.numpy"JAX doesn't allow item assignment.reasonarray_api_strictz_`array_api_strict.where` `fillvalue` doesn't accept Python floats. See data-apis/array-api#807.skip_xp_backendsc                       \ rS rSr\R
                  " \R                  5      R                  rS r	\
" SSS9S 5       rS rS r\
" S	S
S9S 5       rS r\
" S	S
S9S 5       rS rSrg)TestTrimmedStatsL   c           	      D   UR                  [        R                  5       5      n[        R                  " USS5      n[        X1R                  S5      5        [        R                  " USSS9n[        R                  " US S9n[        XE5        UR                  UR                  S5      S5      n[        R                  " US S	9n[        X1R                  U5      5        [        R                  " US
S	9n[        X1R                  US
S	95        [        R                  " USS	9n[        X1R                  USS	95        [        R                  " USS S9n[        X1R                  S5      5        [        R                  " USS
S9n/ SQn[        X1R                  U5      5        [        R                  " USSS
S9n/ SQn[        X1R                  U5      5        [        U5      nUR                  USSS 24'   [        R                  " USS
S9nSSSSUR                  UR                  UR                  /n[        X1R                  U5      5        [        R                  " USSS9nSSSSUR                  UR                  UR                  UR                  UR                  /	n[        X1R                  U5      5        [        R                  " USSSS9nSSSSUR                  UR                  UR                  UR                  UR                  /	n[        X1R                  U5      5        g ) Nr1   r7   TT      @)FFlimits	inclusiverQ        O@r8   r6   axisr   r   )r1   =   )rQ   rW   g     ?@)r1      )         '@r8   
            TF)rQ   rR   rW   )      %@r[   r8   r\   r]   r^   r_   )r   r_   r6   r>   r?   r@   r3   r\      rY   FT)asarrayXtoliststatstmeanr/   reshaper   meanr*   nan)	selfxpxyy1y2x_2dy_truex_2d_with_nans	            O/var/www/html/venv/lib/python3.13/site-packages/scipy/stats/tests/test_stats.py
test_tmeanTestTrimmedStats.test_tmeanW   s\   JJqxxz"KK6<0::c?+[[6^D[[4(zz"))C.&1KK4(774=)KK1%774a701KK1%774a701KKW48::d+,KKW15.::f-.KKWAN0::f-.!#b"#gKKgA>S#sBFFBFFBFF;::f-.KKW15RRH::f-.KKW"/a9r2r266266266266266J::f-.    cupycupy/cupy#8391rE   c                    UR                  [        R                  5       5      n[        U5      n[        R
                  " USSS9n[        XAR                  S5      5        [        R
                  " US S9n[        XCR                  USS95        UR                  UR                  S5      S	5      n[        R
                  " US S
9n[        XCR                  USS95        [        R
                  " USS
9n[        XAR                  SS5      5        [        R
                  " USS
9n[        XAR                  SS5      5        [        R
                  " USSSS9n[        US   UR                  S5      5        [        R
                  " USSSS9n[        US   UR                  S5      5        [        US   UR                  UR                  5      5        g )NrM   rN   rP   g@rS   r   
correctionrT   rU   rV   r   r6   g     v@)r8   g㪪@r   r4   )rQ   rW   rR   r<   r   r5   g@)rf   rg   rh   r)   ri   tvarr/   varrk   r   fullr0   rm   )rn   ro   rp   xp_testrq   rt   s         rw   	test_tvarTestTrimmedStats.test_tvar   sc    JJqxxz"!!$JJq<@::&89:JJq&;;qQ;78zz"))C.&1JJt$';;t;:;JJt!$774/0JJt!$77445 JJtFlK!bjjo. JJtFlK!bjj):;<!bjj01rz   c                     UR                  [        R                  5       5      n[        U5      n[        R
                  " USS5      n[        XAR                  S5      5        [        R
                  " US S9n[        XCR                  USS95        g )NrM   rN   gBĆ/H@rS   r   r~   )rf   rg   rh   r)   ri   tstdr/   std)rn   ro   rp   r   rq   s        rw   	test_tstdTestTrimmedStats.test_tstd   si    JJqxxz"!!$JJq&,/::&89:JJq&;;qQ;78rz   c           	         UR                  S5      n[        [        R                  " U5      UR	                  S5      5        [        [        R                  " USS9UR	                  S5      5        [        [        R                  " USSS9UR	                  S5      5        UR                  US5      n[        [        R                  " USSS9UR	                  SS/5      5        [        [        R                  " USS	9UR	                  / S
Q5      5        [        [        R                  " US S	9UR	                  S5      5        UR                  S5      nUR                  US'   [        [        R                  " U5      UR	                  UR                  5      5        UR                  S5      R                  SS5      n[        R                  " USSS9n[        X1R	                  [        R                  SSS/5      5        g )Nr\   r   )
lowerlimitF)r   rR   r   r4   r1   r1   rV   )r   r1   r3   r5   r7         $@r8      r3   )r   rW   r7   r^   )r   r0   ri   tminrf   rk   rm   np)rn   ro   rp   ress       rw   	test_tminTestTrimmedStats.test_tmin   s]   IIbM

1rzz!}5

13RZZ]C

1eDbjjQRmTJJq&!

1eD

Aq6*	,

11-rzz//JK

140"**Q-@IIcNvv!

1rzz"&&'9: IIbM!!!Q'jjqq1ZZAr(:;<rz   Tz4Only NumPy arrays support scalar input/`nan_policy`.np_onlyrF   c                 D   [        [        R                  " S5      S5        [        R                  " S5      n[        R
                  US'   [        5        nUR                  [        S5        [        [        R                  " USS9S5        Sn[        [        US	9   [        R                  " US
S9  S S S 5        Sn[        [        US	9   [        R                  " USS9  S S S 5        S S S 5        g ! , (       d  f       NE= f! , (       d  f       N(= f! , (       d  f       g = f)Nr3   r   r8   invalid value*omit
nan_policy        The input contains nan valuesmatchraisenan_policy must be one of...foobar)r   ri   r   r   r   rm   r   recordRuntimeWarningassert_raises
ValueErrorrn   ro   rp   supmsgs        rw   test_tmin_scalar_and_nanpolicy/TestTrimmedStats.test_tmin_scalar_and_nanpolicy        	UZZ]A&IIcNvv! CJJ~'78A&92>1Cz5

11 60Cz5

12 6 !  65 65 ! =   ADC/0DD D/
C=	9D 
D	
D
Dc           
      l   UR                  S5      n[        [        R                  " U5      UR	                  S5      5        [        [        R                  " USS9UR	                  S5      5        [        [        R                  " USSS9UR	                  S5      5        UR                  US5      n[        [        R                  " USSS9UR	                  SS/5      5        [        [        R                  " US	S
9UR	                  / SQ5      5        [        [        R                  " US S
9UR	                  S5      5        UR                  S5      nUR                  US'   [        [        R                  " U5      UR	                  UR                  5      5        [        5        nUR                  [        S5        UR                  UR                  S5      S5      n[        R                  " USS	S9n[        XAR	                  SSS[        R                  /5      5        S S S 5        g ! , (       d  f       g = f)Nr\   r8   )
upperlimitF)r   rR   r7   r   r6   r   rV   r   r2   r4   r6   r8   r   zAll-NaN slice encounteredr   )r3   r3   r]   )r   rW   r2   )r   r0   ri   tmaxrf   rk   rm   r   filterr   r   )rn   ro   rp   r   r   s        rw   	test_tmaxTestTrimmedStats.test_tmax   s~   IIbM

1rzz!}5

13RZZ]C

1eDbjjQRmTJJq&!

1eD

Aq6*	,

11-rzz//JK

140"**Q-@IIcNvv!

1rzz"&&'9:  CJJ~'BC

299R=&1A**Q2A6CCQ2rvv,>!?@	 !  s   "A:H%%
H3c                 D   [        [        R                  " S5      S5        [        R                  " S5      n[        R
                  US'   [        5        nUR                  [        S5        [        [        R                  " USS9S5        Sn[        [        US	9   [        R                  " US
S9  S S S 5        Sn[        [        US	9   [        R                  " USS9  S S S 5        S S S 5        g ! , (       d  f       NE= f! , (       d  f       N(= f! , (       d  f       g = f)Nr3   r   r5   r   r   r         "@r   r   r   r   r   )r   ri   r   r   r   rm   r   r   r   r   r   r   s        rw   test_tax_scalar_and_nanpolicy.TestTrimmedStats.test_tax_scalar_and_nanpolicy   r   r   c                 j   UR                  [        R                  5       5      n[        U5      n[        R
                  " USSS9nUR                  / SQ5      n[        XCR                  USS9[        U5      S-  -  5        [        [        R
                  " USS	/S
9[        R
                  " US S
95        g )N)r2   r7   re   rP   )      @rO         @      @       @r   r~   r:   rb   r\   rS   )	rf   rg   rh   r)   ri   tsemr/   r   r-   )rn   ro   rp   r   rq   y_refs         rw   	test_tsemTestTrimmedStats.test_tsem   s    JJqxxz"!!$JJq=A

/0;;u;;genc>QQR

1b"X6

1T8RSrz    N)__name__
__module____qualname____firstlineno__r   finfofloat64	precisiondprecrx   rH   r   r   r   r   r   r   r   __static_attributes__r   rz   rw   rJ   rJ   L   s     HHRZZ **E,/\ f-/2/2:9=, dSU3U3A0 dSU3U3Trz   rJ   c                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rSrg)TestPearsonrWilkinsoni     W.II.D. Compute a correlation matrix on all the variables.

All the correlations, except for ZERO and MISS, should be exactly 1.
ZERO and MISS should have undefined or missing correlations with the
other variables.  The same should go for SPEARMAN correlations, if
your program has them.
c                 d    [         R                  " [        [        5      nUS   n[        US5        g Nr         ?)ri   pearsonrrg   r
   rn   rq   rs      rw   test_pXXTestPearsonrWilkinson.test_pXX  s%    NN1QaDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   r   rg   BIGr
   r   s      rw   
test_pXBIG TestPearsonrWilkinson.test_pXBIG  s%    NN1S!aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   r   rg   LITTLEr
   r   s      rw   test_pXLITTLE#TestPearsonrWilkinson.test_pXLITTLE  s%    NN1V$aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   r   rg   HUGEr
   r   s      rw   test_pXHUGE!TestPearsonrWilkinson.test_pXHUGE   %    NN1T"aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   r   rg   TINYr
   r   s      rw   test_pXTINY!TestPearsonrWilkinson.test_pXTINY%  r   rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   r   rg   ROUNDr
   r   s      rw   test_pXROUND"TestPearsonrWilkinson.test_pXROUND*  s%    NN1U#aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[        US5        g r   )ri   r   r   r
   r   s      rw   test_pBIGBIG"TestPearsonrWilkinson.test_pBIGBIG/  s%    NN3s#aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   r   r   r   r
   r   s      rw   test_pBIGLITTLE%TestPearsonrWilkinson.test_pBIGLITTLE4  s%    NN3v&aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   r   r   r   r
   r   s      rw   test_pBIGHUGE#TestPearsonrWilkinson.test_pBIGHUGE9  %    NN3t$aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   r   r   r   r
   r   s      rw   test_pBIGTINY#TestPearsonrWilkinson.test_pBIGTINY>  r   rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   r   r   r   r
   r   s      rw   test_pBIGROUND$TestPearsonrWilkinson.test_pBIGROUNDC  s%    NN3u%aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[        US5        g r   )ri   r   r   r
   r   s      rw   test_pLITTLELITTLE(TestPearsonrWilkinson.test_pLITTLELITTLEH  s%    NN6&)aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   r   r   r   r
   r   s      rw   test_pLITTLEHUGE&TestPearsonrWilkinson.test_pLITTLEHUGEM  %    NN6$'aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   r   r   r   r
   r   s      rw   test_pLITTLETINY&TestPearsonrWilkinson.test_pLITTLETINYR  r  rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   r   r   r   r
   r   s      rw   test_pLITTLEROUND'TestPearsonrWilkinson.test_pLITTLEROUNDW  s%    NN6%(aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[        US5        g r   )ri   r   r   r
   r   s      rw   test_pHUGEHUGE$TestPearsonrWilkinson.test_pHUGEHUGE\  %    NN4%aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   r   r   r   r
   r   s      rw   test_pHUGETINY$TestPearsonrWilkinson.test_pHUGETINYa  r  rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   r   r   r   r
   r   s      rw   test_pHUGEROUND%TestPearsonrWilkinson.test_pHUGEROUNDf  %    NN4&aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[        US5        g r   )ri   r   r   r
   r   s      rw   test_pTINYTINY$TestPearsonrWilkinson.test_pTINYTINYk  r  rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   r   r   r   r
   r   s      rw   test_pTINYROUND%TestPearsonrWilkinson.test_pTINYROUNDp  r  rz   c                 d    [         R                  " [        [        5      nUS   n[        US5        g r   )ri   r   r   r
   r   s      rw   test_pROUNDROUND&TestPearsonrWilkinson.test_pROUNDROUNDu  s%    NN5'aDAc"rz   r   N)r   r   r   r   __doc__r   r   r   r   r   r   r   r   r   r   r   r   r  r  r
  r  r  r  r  r  r  r   r   rz   rw   r   r     sp    #
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#rz   r   T)cpu_onlyc                      \ rS rSr\" SS9S 5       r\" SSS9S 5       r\" SSS9S	 5       r\" SSS9S
 5       r\" SSS9S 5       r	\" SSS9\
R                  R                  SSS/5      S 5       5       r\" SSS9S 5       r\" SSS9S 5       r\" SSS9S 5       r\" SSS9S 5       r\" SSS9S 5       r\" SSS9S 5       r\
R                  R	                  SS9\
R                  R                  S/ SQ5      S 5       5       r\" SSS9S 5       r\" SSS9S 5       r\
R                  R	                  SS9S 5       r\
R                  R1                  S5      \
R                  R	                  SS9\
R                  R3                  S5      \
R                  R                  SS 5      \
R                  R                  S!S"5      S# 5       5       5       5       5       r\
R                  R	                  SS9\
R                  R                  SS 5      S$ 5       5       r\
R                  R	                  SS9\
R                  R                  S%S&S'/5      S( 5       5       r\
R                  R	                  SS9S) 5       rS* r\" SSS9S+ 5       r\" SSS9\
R                  R                  S%/ S,Q5      \
R                  R                  S/ S Q5      S- 5       5       5       r S.r!g/)0TestPearsonri{  Tr   c                     [         R                  " [        [        5      nSn[        X5        [	        UR
                  UR                  5        g Ncorrelationpvalue)ri   r   rg   r   r   r(  	statisticrn   r   
attributess      rw   test_pearsonr_result_attributes,TestPearsonr.test_pearsonr_result_attributes  s1    nnQ".
C,S__cmm4rz   rC   )JAX arrays do not support item assignmentrE   c           
         UR                  S5      n[        R                  " X"5      u  p4[        X1R	                  S5      SS9  [        XAR	                  S5      [
        R                  " S[
        R                  " S5      -  5      S9  g )N      @r   V瞯<atolr   r1   r   ri   r   r/   rf   r   sqrtspacingrn   ro   ar   probs        rw   test_r_almost_exactly_pos1'TestPearsonr.test_r_almost_exactly_pos1  s]     IIcN..&::c?7 	jjoBGGAbjjo<M4NOrz   c           
         UR                  S5      n[        R                  " X"* 5      u  p4[        X1R	                  S5      SS9  [        XAR	                  S5      [
        R                  " S[
        R                  " S5      -  5      S9  g )Nr1        r2  r3  r   r1   r   r5  r8  s        rw   test_r_almost_exactly_neg1'TestPearsonr.test_r_almost_exactly_neg1  s`     IIcN..B'::d+%8 	jjoBGGAbjjo<M4NOrz   c                     UR                  / SQ5      nUR                  / SQ5      n[        R                  " X#5      u  pE[        XAR                  S5      5        [        XQR                  S5      5        g )Nrb   r   r   )r   r   r2   LXz?UUUUUU?)rf   ri   r   r/   )rn   ro   r9  br   r:  s         rw   
test_basicTestPearsonr.test_basic  sQ    
 JJz"JJy!..&::h/0jjo.rz   c                    Sn[         R                  " [        R                  US9   UR	                  / SQ5      nUR	                  / SQ5      n[        R
                  " X45      u  pV[        XQR	                  UR                  5      5        [        XaR	                  UR                  5      5        S S S 5        g ! , (       d  f       g = f)NAn input array is constantr   MbX?rK  rK  rh|?v/?gsh|??pytestwarnsri   ConstantInputWarningrf   r   r/   rm   rn   ro   r   rp   rq   r   ps          rw   test_constant_input TestPearsonr.test_constant_input  s     +\\%44C@

01A

01A>>!'DAAzz"&&12Azz"&&12 A@@   BB66
Cdtyper   r   c                    [        [        U5      n[        X5      nUR                  SSS[        R                  " SUS9-   /US9nUR                  SSSS[        R                  " SUS9-  -   /US9nSn[        R
                  " [        R                  US9   [        R                  " XE5        S S S 5        g ! , (       d  f       g = f)Nr1   rX  r2   r5   z/An input array is nearly constant; the computedr   )	getattrr   rf   r7  rP  rQ  ri   NearConstantInputWarningr   )rn   ro   rX  npdtyperp   rq   r   s          rw   test_near_constant_input%TestPearsonr.test_near_constant_input  s    
 "e$"JJ1a"**Qg">>?uJMJJ1a!BJJq$@"@@AJO?\\%88D NN1  EDDs   B66
Cc                 0   UR                  / SQUR                  S9nUR                  / SQUR                  S9n[        R                  " X#5      u  pE[	        XAR                  SUR                  S95        [	        XQR                  SUR                  S95        g )N)gy)r?gxd{s?gnp?g$9"o?ge =:k?rZ  )goȟg`
,gzg2l?g>??'ge;E?g3R?rf   r   ri   r   r/   rn   ro   rp   rq   r   rT  s         rw   test_very_small_input_values)TestPearsonr.test_very_small_input_values  s     JJVZZ  )JJNZZ  )~~a# 	::&8

:KL::&8

:KLrz   c                 8   SUR                  / SQUR                  S9-  nSUR                  SUR                  S9-  n[        R                  " X#5      u  pE[        XAR                  SUR                  S95        [        XQR                  SUR                  S95        g )NgY)	kR)r   r   r   r   r   r   r   rZ  r6   rC  g͗~-?)rf   r   r   ri   r   r/   rb  s         rw   test_very_large_input_values)TestPearsonr.test_very_large_input_values  s     1DD1BJJ//~~a# 	::&8

:KL::&:"**:MNrz   c                 0   UR                  / SQUR                  S9nUR                  / SQUR                  S9n[        R                  " X#5      u  pE[	        XAR                  SUR                  S95        [	        XQR                  SUR                  S95        g )N)g7	igNig_b4igZbirZ  )gDig<'(½igmQiZbtig*D{?gݣ?ra  rb  s         rw   !test_extremely_large_input_values.TestPearsonr.test_extremely_large_input_values  sx     JJ9JLJJ;2::JN~~a# 	::&7rzz:JK::&7rzz:JKrz   rD   c                 $   UR                  SS/5      nUR                  SS/5      n[        R                  " X#5      nUu  pVUR                  S5      n[        XW5        [        Xg5        UR	                  5       u  p[        X* 5        [        X5        g )Nr          @r1  rO   rf   ri   r   r0   confidence_interval
rn   ro   rp   rq   r   r   rT  onelowhighs
             rw   test_length_two_pos1!TestPearsonr.test_length_two_pos1  s|     JJBx JJBx nnQ"jjn++-	T""rz   c                 &   UR                  SS/5      nUR                  SS/5      n[        R                  " X#5      nUu  pVUR                  S5      n[        XW* 5        [        Xg5        UR	                  5       u  p[        X* 5        [        X5        g )Nrm  r   r1  rO   rn  rp  s
             rw   test_length_two_neg1!TestPearsonr.test_length_two_neg1  s~     JJBx JJBx nnQ"jjn4 ++-	T""rz   c                    Sn[         R                  " [        R                  US9   UR	                  SS/5      nUR	                  SS/5      n[        R
                  " X45      u  pV[        XQR	                  UR                  5      5        [        XaR	                  UR                  5      5        S S S 5        g ! , (       d  f       g = f)NrI  r   rK  rM  rN  rO  rS  s          rw   test_length_two_constant_input+TestPearsonr.test_length_two_constant_input  s    
 +\\%44C@

E5>*A

E5>*A>>!'DAAzz"&&12Azz"&&12 A@@rW  z$alternative, pval, rlow, rhigh, sign))	two-sided?gmgƎ?r   )lessK˅?rb   g?
?r   )greater.?gդζr   r   )r|  r}  gfǎgl?rb   )r~  r  r>  gդζ?rb   )r  r  g?
r   rb   c                     / SQn[         R                  " / SQ5      U-  n[        R                  " XgUS9n[	        UR
                  SU-  SS9  [	        UR                  USS9  UR                  5       n	[	        XU4SS9  g )Nr   r1   r2   r3   )r   r   r:   r   alternativeg?r9   rtolư>)r   r   ri   r   r   r*  r)  ro  )
rn   r  pvalrlowrhighsignrp   rq   resultcis
             rw   test_basic_exampleTestPearsonr.test_basic_example)  sp     HH^$t++>((*<T*ANt$7'')5M5rz   c                    UR                  S5      nU* n[        R                  " X#SS9n[        R                  " X#SS9n[        UR                  UR                  S5      5        [        UR                  UR                  S5      SS9  g )	Nr   r  r  r~  r   r   g#B;r3  )r   ri   r   r/   r)  rf   )rn   ro   rp   rq   test_greater	test_lesss         rw   (test_negative_correlation_pvalue_gh177955TestPearsonr.test_negative_correlation_pvalue_gh17795:  sj     IIcNB~~a	BNN1V<	++RZZ^<	(("**R.uErz   c                 ,   UR                  / SQ5      nUR                  / SQ5      n[        R                  " X#5      nUu  pVUR                  S5      n[        XW* 5        [        USU-  SS9  UR	                  5       u  p[        X* 5        [        X5        g )Nr   rm  r1  )rO   g      g      *r   r   Hz>r3  )rf   ri   r   r/   ro  r0   rp  s
             rw   #test_length3_r_exactly_negative_one0TestPearsonr.test_length3_r_exactly_negative_oneD  s     JJ|$JJ'nnQ" jjo4 1S5t,++-	T""rz   c                 L   / SQnSS/nSn[         R                  " [        US9   [        R                  " X5        S S S 5        S/nS/nSn[         R                  " [        US9   [        R                  " X5        S S S 5        / S	Qn/ S	QnS
n[         R                  " [        US9   [        R                  " X5        S S S 5        Sn[         R                  " [        US9   [        R                  " SS/SS/SS9  S S S 5        [        R                  " SS/SS/5      n[         R                  " [        US9   UR                  SS9  S S S 5        g ! , (       d  f       GN= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       g = f)Nr   r1   r2   r3   r4   z3`x` and `y` must have the same length along `axis`.r   r   r1   (`x` and `y` must have length at least 2.)             y              y             z+This function does not support complex dataz"`method` must be an instance of...r2   
asymptoticmethodexact)rP  r   r   ri   r   ro  )rn   rp   rq   messager   s        rw   test_input_validation"TestPearsonr.test_input_validationT  s8   FG]]:W5NN1  6 CC<]]:W5NN1  6 ?]]:W5NN1  6 7]]:W5NNAq6Aq6,? 6 nnaVaV,]]:W5##7#3 65) 65 65 65 65 65s;   E$E"&E3 F7F
E"
E03
F
F
F#r\   z-Monte Carlo method needs > a few kB of memoryr  r~  r  r|  method_namepermutationmonte_carlomonte_carlo2c                    [         R                  R                  S5      nUS:X  a  SOSnUR                  US9nUR                  US9n[        R
                  " US9[        R                  " UR                  4S-  S9[        R                  " S	S9S
.nXq   n[        R                  " XVX(SS9n	[        R                  " XVUSS9n
[        U	R                  U
R                  SS9  [        U	R                  U
R                  SSS9  US:X  ak  [        R                  " S	S9n[        R                  " XVX(SS9n[        UR                  U	R                  5        [        UR                  U	R                  5        g g )Nl   o#[mr  r1   d   )r1     sizerngr1   rvsi  r  rb   )r  r  rW   r  rW   r2  r  {Gz?MbP?r  r4  r  )r   randomdefault_rngnormalri   PermutationMethodMonteCarloMethodr   r   r*  r)  r   )rn   r  r  r  r  rp   rq   methodsr  r   refres2s               rw   test_resampling_pvalue#TestPearsonr.test_resampling_pvaluep  s0    ii##$56&-7xYJJDJ!JJDJ!"'"9"9c"B"'"8"8cjj]1_"M#(#9#9d#CE %nnQ{PRSnnQ{Ds}}5A

CJJTE.(++5F>>!KUWXD7cjj1	 )rz   c                    [         R                  R                  S5      nUR                  SS9nUR                  SS9n[        R
                  " X4USS9n[         R                  R                  S5      n[        R                  " US9nUR                  US9nUR                  5       n[        XxS	S
9  [         R                  R                  S5      n[        R                  " US9nUR                  US9n	[        X5        g )Nl   _Y F r  r  rb   r  l   |#(AkPrandom_stater  gQ?r3  r  )	r   r  r  r  ri   r   BootstrapMethodro  r   )
rn   r  r  rp   rq   r   r  res_ciref_cires_ci2s
             rw   test_bootstrap_ciTestPearsonr.test_bootstrap_ci  s     ii##$45JJHJ%JJHJ%nnQ{D ii##$67&&C8(((7((*V4 ii##$67&&3/)))8(rz   rW   r   r   c                    [         R                  R                  S5      nSnUR                  SU-   S9u  pV[        R
                  " XVUS9nUR                  5       nUS:X  a  UR                  UR                  pe[        UR                  S   5       H  n	[        R
                  " XY   Xi   5      n
U
R                  5       n[        UR                  U	   U
R                  5        [        UR                  U	   U
R                  5        [        UR                  U	   UR                  5        [        UR                  U	   UR                  5        M     g )N   I.v# r8   r\   r1   r  rV   r   )r   r  r  r  ri   r   ro  Trangeshaper   r*  r)  rr  rs  )rn   rW   ro   r  r  rp   rq   r   r  ires_ici_is               rw   test_axis01TestPearsonr.test_axis01  s     ii##K0zzte|z,nnQ-$$&1933qqwwqz"ANN14.E,,.DCMM!,eoo>CJJqM5<<8BFF1Itxx0BGGAJ		2 #rz   c                    [         R                  R                  S5      nSnUR                  SU-   S9u  pE[        R
                  " XES S9nUR                  5       n[        R
                  " UR                  5       UR                  5       5      nUR                  5       n	[        UR                  UR                  5        [        UR                  UR                  5        [        Xy5        g )Nr  r  r  r  rV   )r   r  r  r  ri   r   ro  ravelr   r*  r)  )
rn   ro   r  r  rp   rq   r   r  r  ci_refs
             rw   test_axis_NoneTestPearsonr.test_axis_None  s    ii##K0zzte|z,nnQ-$$&nnQWWY	2((*s}}5

CJJ/#rz   c                    UR                  S5      =p#Sn[        R                  " [        US9   [        R
                  " X#SS9  S S S 5        Sn[        R                  " [        US9   [        R
                  " X!R                  S5      SS9  S S S 5        S	n[        R                  " [        US9   [        R
                  " UR                  S5      UR                  S5      SS9  S S S 5        S
n[        R                  " [        US9   [        R
                  " X!R                  S5      SS9  S S S 5        Sn[        U5      (       d\  UR                  S5      n[        R                  " [        US9   [        R
                  " X"[        R                  " 5       S9  S S S 5        g g ! , (       d  f       GNf= f! , (       d  f       GN0= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       g = f)N)r1   r4   z`axis` must be an integer.r   r;   rV   z2`x` and `y` must have the same length along `axis`r1   r   r   r  z"`x` and `y` must be broadcastable.r2   r4   z:`method` must be `None` if arguments are not NumPy arrays.r\   r  )	onesrP  r   r   ri   r   r+   r   r  )rn   ro   rp   rq   r  s        rw   test_nd_input_validation%TestPearsonr.test_nd_input_validation  sP   .]]:W5NN1c* 6 G]]:W5NN1ggfoA6 6 =]]:W5NN2776?BGGFO!D 6 7]]:W5NN1ggfoA6 6 O||		"Az9qE,C,C,EF :9 ! 65 65 65 65 :9s;   F#'%F5/5G%G0)G)#
F25
G
G
G&)
G7c                    [         R                  R                  S5      nUR                  UR                  S5      5      nUR                  UR                  S5      5      nSn[        R
                  " [        R                  US9   [        U5      nSUS'   [        R                  " XdSS9nUR                  5       nUR                  UR                  UR                  S9n	[        UR                  S	   U	5        [        UR                  S	   U	5        [        UR                   S	   U	5        [        UR"                  S	   U	5        UR%                  UR'                  UR                  SS  5      5      (       a   eUR%                  UR'                  UR                  SS  5      5      (       a   eUR%                  UR'                  UR                   SS  5      5      (       a   eUR%                  UR'                  UR"                  SS  5      5      (       a   e S S S 5        S
n[        R
                  " [        R(                  US9   SWS'   [        R                  " XdSS9  S S S 5        UR                  SS/SS/SS/SS//5      nUR                  SS/SS/SS/SS//5      n
UR+                  S5      n[        R                  " XjSS9nUR                  5       n[-        UR                  UR                  / SQ5      5        [-        UR                  U5        [-        UR                   U* 5        [-        UR"                  U5        g ! , (       d  f       GN2= f! , (       d  f       N= f)Nl   U!Jr  rI  r   r   )r   .rV   rZ  r   z!An input array is nearly constantg     ?r   r   r1   r   r3   rb   )r   rb   rb   r   )r   r  r  rf   rP  rQ  ri   rR  r*   r   ro  rm   r   r0   r*  r)  rr  rs  anyisnanr\  r  r/   )rn   ro   r  x0y0r  rp   r   r  rm   rq   r  s               rw   test_nd_special_cases"TestPearsonr.test_nd_special_cases  s    ii##N3ZZ

6*+ZZ

6*+.\\%44GDAAfI..Q/C((*B**RVV2::*6CCMM!,c2CJJqM3/BFF1Is+BGGAJ,vvbhhs}}QR'89::::vvbhhszz!"~67777vvbhhrvvabz23333vvbhhrwwqr{344444 E 6\\%88HAdGNN1q) I
 JJAAAB89JJAAAB89wwqznnQ+$$&rzz/'BC

D)&&; ED  IHs   FL?M?
M
M)r   r   Nc                 x   [         R                  SS9u  pE[        R                  " UR	                  U5      UR	                  U5      X#S9n[        R                  " XEX#S9n[        UR                  UR	                  UR                  5      5        [        UR                  UR	                  UR                  5      5        UR                  5       nUR                  5       n	[        UR                  UR	                  U	R                  5      5        [        UR                  UR	                  U	R                  5      5        g )N)r1   r\   r]   r  rW   r  )r  r  ri   r   rf   r/   r*  r)  ro  rr  rs  )
rn   ro   rW   r  rp   rq   r   r  r  r  s
             rw   test_array_apiTestPearsonr.test_array_api  s    
 zz{z+nnRZZ]BJJqM"&AnnQFrzz#--'@A

BJJszz$:;((*((*

BJJvzz$:;RZZ%<=rz   r   N)"r   r   r   r   rH   r-  r;  r?  rF  rU  rP  markparametrizer^  rc  rf  rj  rt  rw  rz  r  r  r  r  	fail_slowxfail_on_32bitr  r  r  r  r  r  r  r   r   rz   rw   r#  r#  {  s    d#5 $5 kHJPJP kHJPJP kHJ/J/ kH	3	3 kH [[Wy)&<=
! >
! kHMM kHOO kHJLJL k*NO# P# k*NO# P# k*NO
3 P
3& [[!!$!/[[CHI6I 06 kHJFJF kHJ#J# [[!!$!/4 046 [[2[[!!$!/[[ OP[[],LM[[]KM2M N Q 0 2( [[!!$!/[[],LM) N 0)& [[!!$!/[[VaV,3 - 03  [[!!$!/
$ 0
$G0 kHJ#'J#'J kHJ[[V\2[[],LM> N 3J>rz   r#  c                      \ rS rSrSrS rS rS rS r\	R                  R                  S 5       rS rS	 rS
 rS r\	R                  R#                  S/ SQ5      S 5       rS r\	R                  R)                  S5      \	R                  R                  5       S 5       5       r\	R                  R)                  S5      \	R                  R                  5       S 5       5       r\	R                  R/                  5       S 5       rSrg)TestFisherExacti  a  Some tests to show that fisher_exact() works correctly.

Note that in SciPy 0.9.0 this was not working well for large numbers due to
inaccuracy of the hypergeom distribution (see #1218). Fixed now.

Also note that R and SciPy have different argument formats for their
hypergeometric distribution functions.

R:
> phyper(18999, 99000, 110000, 39000, lower.tail = FALSE)
[1] 1.701815e-09
c                    [         R                  nU" SS/SS//5      S   n[        USSS9  U" S	S
/SS//5      S   n[        USSS9  U" S
S/SS
//5      S   n[        USSS9  U" SS/SS//5      S   n[        USSS9  U" SS/SS//5      S   n[        USSS9  U" SS/SS//5      S   n[        USSS9  U" SS/SS//5      S   n[        USSS9  U" SS/SS//5      S   n[        USSS9  U" SS/SS
//5      S   n[        US5        U" SS
/SS//5      S   n[        US5        U" S
S/SS
//5      n[        US   SSS9  [        US   S5        g ) N8   N  0u  @  r   g؞Y?r3   significantr  r1   r  r4   g,Ԛ?r6   r7   g2c?r5   r\   gY
A?      g_?r      gO^M?r   gօa?r2   r   ggE?g$I$I?)ri   fisher_exactr
   )rn   r   r   s      rw   rF  TestFisherExact.test_basic  s   ))UENUEN;<Q?Ca8S!HtQi01!4CQ7QFQF+,Q/C:QFRH-.q1C:QGb"X./2C:QGb"X./2C:RGb!W-.q1C:QFQF+,Q/C;QFQF+,Q/C%QFQF+,Q/C.QFQF+,CFI1=CFH-rz   c                    SS/SS//S4SS/SS//S4SS	/S
S
//S4SS/SS//S4SS/SS//S4S
S/S
S	//S4S
S/S
S//S4SS/S	S//[         R                  S44SS/S	S//S4SS	/SS//[         R                  S44SS	/SS//S4/nU HU  u  p#[        R                  " [         R                  " U5      5      n[         R
                  R                  US	   US	   SSS9  MW     g )Nr  r1   r  r4   )gAn&	?g}K
T?r6   r7   )g	7?g?r   r\   )g!@j)A?r  r  )gU!a?gKY?r   r  )g7X?g~ltP?)gFu|?r  r   )r   gQN^?r3   gaa?r   r   gaa?r2   r]   T)decimalverbose)r   infri   r   rf   testingr   )rn   tablisttableres_rr   s        rw   test_preciseTestFisherExact.test_precise8  s^    Ahq	"$TU!fq!fOP!fr2h!QR"gBx "RS"gBx "RS1gAw!QR1gAw!QR!fq!f(>?@!fq!fOP!fq!f(>?@!fq!fOP $LE$$RZZ%67CJJ**3q658R37 + 9 $rz   c                    SS/SS//n[         R                  " U5      n[        US   S5        SS/SS	//n[         R                  " U5      n[        US   S
5        SS/SS//n[         R                  " U5      n[        US   S5        g )Nr5   %   l      r   gmt?   r   f   g,:^   0   i  i\B  gNQ8ri   r   r   rn   rp   r   s      rw   test_gh4130TestFisherExact.test_gh4130P  s     WsCj!  #A 12 !Wq#h  #A 56 "Xe}%  #A 56rz   c                 \    SS/SS//n[         R                  " U5      n[        US   SSS9  g )NiiX iV iW r   r   gѧRr3  r  r  s      rw   test_gh9231TestFisherExact.test_gh9231f  s8     w'7!34  #A/rz   c                     / SQn[        U/ SQ5       H.  u  p#[        R                  " SS/SU//5      S   n[        XBSS9  M0     [        R                  " S	S
/SS//5      S   n[        USSS9  g )N)g?=gNuP=gs=)K   rK   M   i(E  i  i)  r   r3   r  iPF  i8 r  i_ g^K=?)zipri   r   r
   )rn   pvalsr  numr   s        rw   test_large_numbers"TestFisherExact.test_large_numbersm  sx     1UL1ID$$uclT3K%@A!DCq9 2   5%.5%.!AB1ECQ7rz   c                     Sn[         R                  " [        US9   [        R                  " [
        R                  " S5      5        S S S 5        g ! , (       d  f       g = f)Nz+The input `table` must have two dimensions.r   r5   )rP  r   r   ri   r   r   r   rn   r  s     rw   test_raisesTestFisherExact.test_raisesx  s7    ?]]:W5ryy|, 655s   +A
Ac                     SS/SS//SS/SS//SS/SS//SS/SS//4nU HA  n[         R                  " U5      u  p4[        US5        [        U[        R                  5        MC     g )Nr   r4   r\   r   )ri   r   r   r   rm   )rn   tablesr
  	oddsratior  s        rw   test_row_or_col_zero$TestFisherExact.test_row_or_col_zero~  s    q6Ar7#r7QF#q6Ar7#q6B7#% E#007OIs#BFF+ rz   c                    SS/SS//SS/SS//SS/SS	//S
S/SS//SS/SS//SS/SS//SS/SS//SS/SS//SS/SS//4	nSS/SS/SS/SS/SS/SS/SS/SS/SS/4	n[        X5       H`  u  p4/ nUR                  [        R                  " USS9S   5        UR                  [        R                  " US S9S   5        [	        XTSS!S"9  Mb     g )#Nr1   r6   r7   r  i,     rY   r5   i     i   i  r   r2   r   r3   gI[?gq}!?r   g2\&gQp6g:O_?g a?皙?ffffff??333333?UUUUUU?rD  r~  r  r  r  )r4  r  )r   appendri   r   r   )rn   r*  r!  r
  r  r   s         rw   test_less_greater!TestFisherExact.test_less_greater  sL    VaV1X3x "X4y!3Z#s$ VaVVaVVaVVaVVaV  "#56)*()	"#J#J#J3K$K v-KECJJu))%VDQGHJJu))%YGJKCAD9	 .rz   c                 @    [         R                  " SS/SS//5      u  pg )Nr   r1   r8   i")ri   r   )rn   oddsr)  s      rw   test_gh3014TestFisherExact.test_gh3014  s%     ))Aq6Ax=*ABfrz   r  r|  r~  r  c                     [         R                  " SS/SS//5      n[        R                  " X!S9n[	        UR
                  UR                  4U5        g )Nr  r  r  r  r  )r   r   ri   r   r   r*  r)  )rn   r  r
  r   s       rw   test_resultTestFisherExact.test_result  sD    5%.5%.9:  @cmmSZZ0#6rz   c                    [         R                  R                  S5      n[         R                  " SS/SS//5      nSn[        R
                  " [        US9   [        R                  " US9n[        R                  " X$SS	9  S S S 5        S
n[        R
                  " [        US9   [        R                  " US9n[        R                  " X$S9  S S S 5        Sn[        R
                  " [        US9   [        R                  " [        R                  R                  S9n[        R                  " X$S9  S S S 5        Sn[        R
                  " [        US9   [        R                  " [         R                  " S5      5        S S S 5        [         R                  R!                  [        R                  " / SQ/5      S5        [         R                  R!                  [        R                  " S/S/S//5      S5        [         R                  R!                  [        R                  " [         R                  " S5      5      S5        g ! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN;= f! , (       d  f       N= f)N   9o8o r1   r6   r7   z4`alternative` must be the default \(None\) unless...r   r  r~  r  r  z6...not recognized; if provided, `method` must be an...r  z3If the `method` argument of `fisher_exact` is an...r  z2`table` must have at least one row and one column.r   r   r  r   r   r   r2   r1   r2   )r   r  r  rf   rP  r   r   ri   r  r   r  r  normr  zerosr  r   )rn   r  r
  r  r  s        rw   $test_input_validation_edge_cases_rxc4TestFisherExact.test_input_validation_edge_cases_rxc  s   ii##$78

QFQF+,I]]:W5,,5FuH 6 K]]:W5**s3Fu4 6 H]]:W5++

?Fu4 6 G]]:W5rxx/0 6
 	

 2 2I; ?H


 2 2QC!qc? CVL


 2 2288F3C DfM- 65
 65
 65
 65s1   *I$)I0AI%+I7
I
I"%
I47
Jr\   c                    [         R                  R                  S5      n[         R                  " SS/SS//5      n[        R
                  " U5      nUR                  n[        R                  " UR                  SS9UR                  SS95      R                  U5      n[        R                  " US9n[        R
                  " X&S	9n[        UR                  US
S9  [        UR                  U5        [        R                  " US9n[        R
                  " X&S	9n[        UR                  UR                  S
S9  [        UR                  U5        g )NrB  r1   r6   r7   r   rV   r   r  r  g{Gzd?r3  )r   r  r  rf   ri   r   r)  random_tablesumpmfr  r   r   r*  r  )rn   r  r
  r  
ref_pvalueref_statr  r   s           rw   test_resampling_2x2#TestFisherExact.test_resampling_2x2  s    ii##$78

QFQF+,  'ZZ
%%eiiQi&79JKOOPUV''C0  6

JV<S]]H-((S1  6

CJJV<S]]H-rz   c                    / SQ/ SQ/ SQ/ SQ/ SQ/n[         R                  " U5      nSn[         R                  R                  S5      n[        R
                  " US9n[        R                  " XS	9n[        UR                  US
S9  [        R                  " USS9n[        R                  " XS	9n[        UR                  US
S9  g )N)r   r1   r1   r   r   r   r   )r1   r   r   r1   r2   r   r   )r   r   r   r   r1   r6   r2   )r   r   r1   r   r   r   r   )r   r   r   r   r   r   r   gk$?l   |Kr  r  gMb@?r3  i )r  n_resamples)
r   rf   r  r  ri   r  r   r   r)  r  )rn   r
  rO  r  r  r   s         rw   test_resampling_rxc#TestFisherExact.test_resampling_rxc  s     '&&&&	(
 

5!%
ii##M2((S1  6

JT:''CUC  6

JT:rz   c           
         [         R                  R                  S5      n[        R                  " US9n[        SS5       H  n[        SS5       H  n[        SS5       Hy  n[        SS5       Hf  n[         R                  " X4/XV//5      n[        R                  " U5      n[        R                  " XrS9n	[        U	R                  UR                  SS9  Mh     M{     M     M     g )	NrB  r  r   r2   r3   r  +=r3  )
r   r  r  ri   r  r  rf   r   r   r)  )
rn   r  r  r9  rE  cdr
  r  r   s
             rw   test_resampling_exact_2x2)TestFisherExact.test_resampling_exact_2x2  s     ii##$78((S1q!A1a[q!A"1a[ "

QFQF+; <#007#00F'

CJJUK	 ) % ! rz   r   N)r   r   r   r   r   rF  r  r  r  rP  r  slowr#  r'  r,  r7  r;  r  r?  rI  r  rQ  rU  xslowr[  r   r   rz   rw   r  r    s   .6907,0 [[8 8-, :DC
 [[],LM7 N7
N> [[2[[.  ." [[2[[;  ;: [[L Lrz   r  c                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S  r"S! r#S" r$S# r%S$ r&S%r'g&)'TestCorrSpearmanri  r   c                     [         R                  " SS5      n[        [        R                  " U5      R                  5       5        g )Nr   rm  )ri   	spearmanrr   r   r  all)rn   rq   s     rw   test_scalarTestCorrSpearmanr.test_scalar  s)    OOB#!"rz   c                     [        [        [        R                  / SQSS/5        [        [        [        R                  / SQS5        g )Nr   r1   r   r7   r8   )r   r   ri   rb  rn   s    rw   test_uneven_lengths%TestCorrSpearmanr.test_uneven_lengths#  s*    j%//9q!fEj%//9a@rz   c                 N   [         R                  R                  S5        [         R                  R                  SS5      n[         R                  R                  SS5      n[        R
                  " X5      R                  R                  S:X  d   e[        R
                  " UR                  UR                  SS9R                  R                  S:X  d   e[        [        [        R
                  XSS9  [        [        [        R
                  UR                  UR                  5        g )N鄋 r3   r2   r1   r4   r4   r   rV   )r   r  seedrandnri   rb  r*  r  r  r)  r   r   rn   rp   rq   s      rw   test_uneven_2d_shapes'TestCorrSpearmanr.test_uneven_2d_shapes'  s    
		vIIOOAq!IIOOAq!q$..44>>>qssACCa077==GGGj%//1a@j%//133<rz   c           	         [         R                  R                  S5        [         R                  R                  SSS5      n[	        [
        [        R                  U5        [	        [
        [        R                  X5        [	        [
        [        R                  US S 5        [        [        R                  " XS S9[        R                  " UR                  5       UR                  5       SS95        g )Nrl  r3   r2   r1   rV   r   )
r   r  rn  ro  r   r   ri   rb  r   flattenrn   rp   s     rw   test_ndim_too_high$TestCorrSpearmanr.test_ndim_too_high2  s    
		vIIOOAq!$j%//15j%//18j%//1dDA48		QYY[qI	Krz   c                    [         R                  " S5      n[         R                  US'   [        [        R
                  " X5      [         R                  [         R                  45        [        [        R
                  " XSS9S5        [        [        [        R
                  XSS9  [        [        [        R
                  XSS9  g )Nr   r8   r   r   )r   r   r   r   )r   r   rm   r	   ri   rb  r   r   ru  s     rw   test_nan_policy!TestCorrSpearmanr.test_nan_policy<  sx    IIcNvv!5??102662662BC5??1FC%	'j%//1GLj%//1HMrz   c                    [         R                  R                  S5        [         R                  R                  SS5      nSn[         R                  US S 2U4'   [         R
                  " XSS9n[        R                  " USS9u  pE[        R                  " U5      u  pg[         R
                  " [         R
                  " XBSS9USS9n[         R
                  " [         R
                  " XRSS9USS9n[        XFS	S
9  [        XWS	S
9  g )Nr4   r\   r5   r   rV   r   r   r   rX  r3  )	r   r  rn  randrm   deleteri   rb  r   )rn   rp   krq   corxpxcorypys           rw   test_nan_policy_bug_12458+TestCorrSpearmanr.test_nan_policy_bug_12458E  s    
		qIINN1b!&&!Q$IIa#??18??1%yy43QQ?YYryyQ/;/U+rz   c                    [         R                  R                  S5        SnSn[         R                  R                  X5      n[         R                  US'   [         R                  US'   [
        R                  " USSS9u  pE[        U5       VVs/ s HJ  n[        U5       Vs/ s H0  n[
        R                  " X7S S 24   X6S S 24   5      R                  PM2     snPML     nnn[        XH5        g s  snf s  snnf )Nr4   r\   r   r   )r2   rb   r   	propagaterW   r   )
r   r  rn  ro  rm   ri   rb  r  r*  r   )	rn   mnrp   corrr)  jr  r   s	            rw   test_nan_policy_bug_12411+TestCorrSpearmanr.test_nan_policy_bug_12411R  s    
		qIIOOA!&&$66%qq[Ia" 1 FK1XNXQ$a41;;XN  	 "" O "s   C4"7C/C4/C4c                 d    [         R                  " [        [        5      nUS   n[        US5        g r   )ri   rb  rg   r
   r   s      rw   test_sXXTestCorrSpearmanr.test_sXX^  s%    OOAa aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   rb  rg   r   r
   r   s      rw   
test_sXBIGTestCorrSpearmanr.test_sXBIGc  s%    OOAc"aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   rb  rg   r   r
   r   s      rw   test_sXLITTLETestCorrSpearmanr.test_sXLITTLEh  s%    OOAf%aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   rb  rg   r   r
   r   s      rw   test_sXHUGETestCorrSpearmanr.test_sXHUGEm  %    OOAd#aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   rb  rg   r   r
   r   s      rw   test_sXTINYTestCorrSpearmanr.test_sXTINYr  r  rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   rb  rg   r   r
   r   s      rw   test_sXROUNDTestCorrSpearmanr.test_sXROUNDw  s%    OOAe$aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[        US5        g r   )ri   rb  r   r
   r   s      rw   test_sBIGBIGTestCorrSpearmanr.test_sBIGBIG|  s%    OOC$aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   rb  r   r   r
   r   s      rw   test_sBIGLITTLE!TestCorrSpearmanr.test_sBIGLITTLE  s%    OOC'aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   rb  r   r   r
   r   s      rw   test_sBIGHUGETestCorrSpearmanr.test_sBIGHUGE  %    OOC%aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   rb  r   r   r
   r   s      rw   test_sBIGTINYTestCorrSpearmanr.test_sBIGTINY  r  rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   rb  r   r   r
   r   s      rw   test_sBIGROUND TestCorrSpearmanr.test_sBIGROUND  s%    OOC&aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[        US5        g r   )ri   rb  r   r
   r   s      rw   test_sLITTLELITTLE$TestCorrSpearmanr.test_sLITTLELITTLE  s%    OOF6*aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   rb  r   r   r
   r   s      rw   test_sLITTLEHUGE"TestCorrSpearmanr.test_sLITTLEHUGE  %    OOF4(aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   rb  r   r   r
   r   s      rw   test_sLITTLETINY"TestCorrSpearmanr.test_sLITTLETINY  r  rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   rb  r   r   r
   r   s      rw   test_sLITTLEROUND#TestCorrSpearmanr.test_sLITTLEROUND  s%    OOF5)aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[        US5        g r   )ri   rb  r   r
   r   s      rw   test_sHUGEHUGE TestCorrSpearmanr.test_sHUGEHUGE  %    OOD&aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   rb  r   r   r
   r   s      rw   test_sHUGETINY TestCorrSpearmanr.test_sHUGETINY  r  rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   rb  r   r   r
   r   s      rw   test_sHUGEROUND!TestCorrSpearmanr.test_sHUGEROUND  %    OOD'aDAc"rz   c                 d    [         R                  " [        [        5      nUS   n[        US5        g r   )ri   rb  r   r
   r   s      rw   test_sTINYTINY TestCorrSpearmanr.test_sTINYTINY  r  rz   c                 d    [         R                  " [        [        5      nUS   n[	        US5        g r   )ri   rb  r   r   r
   r   s      rw   test_sTINYROUND!TestCorrSpearmanr.test_sTINYROUND  r  rz   c                 d    [         R                  " [        [        5      nUS   n[        US5        g r   )ri   rb  r   r
   r   s      rw   test_sROUNDROUND"TestCorrSpearmanr.test_sROUNDROUND  s%    OOE%(aDAc"rz   c                     [         R                  " [        [        5      nSn[        X5        [	        UR
                  UR                  5        g r&  )ri   rb  rg   r   r   r(  r*  r+  s      rw    test_spearmanr_result_attributes2TestCorrSpearmanr.test_spearmanr_result_attributes  s1    ooa#.
C,S__cmm4rz   c                     / SQn/ SQn[         R                  " X5      n[         R                  " [        R                  " X/5      R                  5      n[        X45        g )Nr   r1   r2   r3   r4   r5   )r   r1   r2   r3   r5   r4   )ri   rb  r   rf   r  r   rn   x1x2res1r  s        rw   test_1d_vs_2dTestCorrSpearmanr.test_1d_vs_2d  sA    r&rzz2(3556#rz   c                    S H  nS[         R                  SSSS/nSSSSS[         R                  /n[        R                  " X#US9n[        R                  " [         R                  " X#/5      R
                  US9n[        XE5        M     g )	N)r  r   r   r2   r3   r4   r5   r1   r   )r   rm   ri   rb  rf   r  r   )rn   r   r  r  r  r  s         rw   test_1d_vs_2d_nans$TestCorrSpearmanr.test_1d_vs_2d_nans  sq    /JRVVQ1a(BQ1a(B??2jAD??2::rh#7#9#9jQDD' 0rz   c                    [         R                  " S5      nU* n[         R                  " / SQ5      n[         R                  " XU/5      R                  n[
        R                  " U5      n[         R                  " / SQ/ SQ/ SQ/5      n[         R                  " S[        S9nSUS	S
S	24'   SUS
S	2S	4'   [        UR                  U5        [        UR                  U5        g )Nr5   )r   r   r1   r2   r4   r3   )r   rb   3+?)rb   r   3+)r  r  r   r2   r2   rZ  g+Hs]s?r1   r   )r   r   r   rf   r  ri   rb  rH  floatr   r*  r)  )rn   r  r  x3rp   actualexpected_correxpected_pvalues           rw   
test_3colsTestCorrSpearmanr.test_3cols  s    YYq\SXX()JJ|$&&#"5"6">"@ A ((67"/1Q3"/!Q((-87rz   c           
         [         R                  " [         R                  SSSSSS/S[         R                  SSS	SS// S
Q/5      R                  n[         R                  " [         R                  [         R                  [         R                  /[         R                  [         R                  [         R                  /[         R                  [         R                  S//5      n[	        [
        R                  " USS9R                  U5        [
        R                  " USS9R                  n[	        US   S   US   S   US   S   4SSS9  g )Nr1  r   rO   ffffff@r   ffffff"@ffffff@g333333@皙@)r:   r   ffffff@ffffff@r   r  ffffff@r   r  r   r   r   r   r1   )gacJC?g%ln?g_0nYt!޿r  r  )r   r   rm   r  r   ri   rb  r*  )rn   rp   r  r   s       rw   test_gh_9103TestCorrSpearmanr.test_gh_9103  s   HHrvvsCc3<BFFCc3<9; <<=A 	
 xx"&&"&&"&&1&&"&&"&&1&&"&&"-/ 0 	kBLL	 ooaF3==QCF1Is1vay9:	Grz   c                 >   Sn[         R                  R                  S5        [         R                  R                  U5      n[         R                  R                  U5      S:  nUS:  n[         R                  " U5      n[
        R                  " XESS9R                  n[         R                  XS'   [
        R                  " XESS9R                  nUR                  [         R                  5      n[
        R                  " XESS9R                  n/ SQn	[        XgU/U	5        g )Nr  iH r2  r:   r   r   )gonj?)Wn%?r  )r   r  rn  r|  r   ri   rb  r*  rm   astypeint32r   )
rn   r  rp   r  r9  rE  r  r  res3expecteds
             rw   test_gh_8111TestCorrSpearmanr.test_gh_8111  s    
		vIINN1IINN1# VHHQKq7AA vvq7AA HHRXXq7AA:T*H5rz   r   N)(r   r   r   r   r   rd  ri  rq  rv  ry  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   rz   rw   r`  r`    s    #A	=KN,
##
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
5$(8 G6rz   r`  c                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS r\R*                  R-                  SS5      S 5       rSrg)TestCorrSpearmanr2i  z-Some further tests of the spearmanr function.c                     / SQn/ SQnSn[         R                  " X5      n[        US   US   5        [        US   US   5        g )Nr   r1   r2   r3   r4   r4   r5   r6   r7   r6   gh
C?gR?r   r   )ri   rb  r
   rn   r  r  r  r   s        rw   test_spearmanr_vs_r&TestCorrSpearmanr2.test_spearmanr_vs_r  sE     >oob%CFHQK0CFHQK0rz   c                     [        [        R                  " / / 5      [        R                  [        R                  45        g N)r   ri   rb  r   rm   rh  s    rw   test_empty_arrays$TestCorrSpearmanr2.test_empty_arrays!  s$    U__R,rvvrvv.>?rz   c           	         [         R                  R                  S5        [         R                  " [         R                  R	                  SSSS9[         R                  R	                  SSSS9/5      nSS/SS//n[         R
                  " [         R                  R                  U5      U5      nSn[        R                  " US   US   5      n[        US   US   5        [        US   US   5        g )	Nz  r     locscaler  r   r4  )gCzYW?ge*=r   )r   r  rn  r   r  dotlinalgcholeskyri   rb  r
   )rn   rp   r  r  r   s        rw   test_normal_draws$TestCorrSpearmanr2.test_normal_draws$  s    
		tHHbii&&1AC&@ii&&1AC&@B Cc
c
FF299%%d+Q/?ooadAaD)CFHQK0CFHQK0rz   c                 T    [        [        R                  " / SQ/ SQ5      S   S5        g )Nr   r   r1   r   r   )r
   ri   rb  rh  s    rw   test_corr_1TestCorrSpearmanr2.test_corr_10  s    EOOIyA!DcJrz   c                    [         R                  " S5      n[         R                  US'   [        [        R
                  " X5      [         R                  [         R                  45        [        [        R
                  " XSS9S5        [        [        [        R
                  XSS9  [        [        [        R
                  XSS9  g )Nr   r8   r   r   )r   r   r   r   )	r   r   rm   r	   ri   rb  r   r   r   ru  s     rw   test_nan_policies$TestCorrSpearmanr2.test_nan_policies3  sx    IIcNvv!5??102662662BC@ 	"j%//1GLj%//1HMrz   c                     [         R                  " S5      n[         R                  " S5      n[        [        [        R
                  X5        g )Nr         4@)r   r   r   r   ri   rb  rp  s      rw   test_unequal_lengths'TestCorrSpearmanr2.test_unequal_lengths<  s,    IIcNIIcNj%//18rz   c                     / SQnSSS[         R                  /n[        R                  " XSS9n[        R                  " US S US S SS9n[	        X45        g )Nr  r7   r6   r5   r   r   r2   )r   rm   ri   rb  r   r  s        rw   test_omit_paired_value)TestCorrSpearmanr2.test_omit_paired_valueA  sO    Arvvr&9r"1vr"1v&AT rz   c                 ^   [        [        S5      5      n[        [        S5      5      nUS   US   sUS'   US'   US   US   sUS'   US'   US   US   sUS'   US'   UR                  [        R                  5        UR                  S5        [        [        R                  " XS	S
9S   S5        g )N  r8   r   i  r\   i  i  r1  r   r   gV-?)listr  r6  r   rm   r   ri   rb  rp  s      rw   #test_gh_issue_6061_windows_overflow6TestCorrSpearmanr2.test_gh_issue_6061_windows_overflowH  s    ttqT1Q4
!ad#""qvD'1S6#$ 	
	EOOAVDQGOrz   c                 h   Sn[         R                  " [        R                  US9   [        R                  " / SQ/ SQ5      u  p#[        U[        R                  5        [        U[        R                  5        [        R                  " / SQ/ SQ5      u  p#[        U[        R                  5        [        U[        R                  5        [        R                  " / SQ/ SQ5      u  p#[        U[        R                  5        [        U[        R                  5        S S S 5        g ! , (       d  f       g = f)NrI  r   r1   r1   r1   r1   r   r1   )rP  rQ  ri   rR  rb  r   r   rm   )rn   warn_msgr   rT  s       rw   	test_tie0TestCorrSpearmanr2.test_tie0U  s    /\\%44HE??9i8DABFF#BFF#??9i8DABFF#BFF#??9i8DABFF#BFF# FEEs   C4D##
D1c                     / SQn/ SQn/ SQn/ SQn[         R                  " X5      n[         R                  " X45      n[        XV5        g )Nr   rm  r1  r   )r   rm  rm  r1  )r   r<   r<   r   )ri   rb  r   r   )rn   rp   rq   xryrsrprs          rw   	test_tie1TestCorrSpearmanr2.test_tie1c  s<      !! __Q"^^B#B#rz   c                     / SQn/ SQnSSSS[         R                  /nSSSS[         R                  /n[        R                  " X5      n[        R                  " X4SS	9n[	        XV5        g )
N)r   r1   r<   r1   )r   r2   r<   r3   r   r1   r<   r2   r3   r   r   )r   rm   ri   rb  r   )rn   r  rr   r  rs   sr1sr2s          rw   	test_tie2TestCorrSpearmanr2.test_tie2p  s^     CBFF#CBFF# oob%oob8C%rz   c                    [         R                  " / SQ/ SQ/5      n[         R                  " / SQ/ SQ/5      n[         R                  " / SQ/ SQ/5      nSn[        R                  " [        R
                  US9   [        R                  " USS9u  pV[        U[         R                  5        [        U[         R                  5        [        R                  " USS9u  pV[        U[         R                  5        [        U[         R                  5        [        R                  " USS9u  pV[        U[         R                  5        [        U[         R                  5        S S S 5        g ! , (       d  f       g = f)Nr   r   r   r   r  rI  r   r   rV   	r   r   rP  rQ  ri   rR  rb  r   rm   )rn   z1z2z3r,  r   rT  s          rw   test_ties_axis_1#TestCorrSpearmanr2.test_ties_axis_1~  s    XX|\23XX|\23XX|\23/\\%44HE??2A.DABFF#BFF#??2A.DABFF#BFF#??2A.DABFF#BFF# FEEs   :C"E%%
E3c                 z   [         R                  " / SQ5      n[         R                  " / SQ5      nSn[        R                  " [        R
                  US9   [        R                  " X5      u  pE[        U[         R                  5        [        U[         R                  5        S S S 5        g ! , (       d  f       g = f)N)
r   r   r   r   r   r   r   r   r   r   
r   gN}	?r   r   g	/`?gY%uX-H?gC1tq1?r   r   g*I?rI  r   r>  )rn   rp   rq   r,  r   rT  s         rw   test_gh_11111 TestCorrSpearmanr2.test_gh_11111  sx    HHGHHH - . 0\\%44HE??1(DABFF#BFF# FEEs   AB,,
B:c                     [         R                  " / SQ5      n[         R                  " / SQ5      n[        [        [        R
                  XSS9  g )N)
r   r   rm  r   r   r   r   r   r   r   rE  r1   rV   )r   r   r   r   ri   rb  rp  s      rw   test_index_error#TestCorrSpearmanr2.test_index_error  s8    HHGHHH - . 	j%//1a@rz   c                    / SQn/ SQnSn[         R                  " XSS9n[        US   US   5        [        US   SUS   S-  -
  5        [         R                  " XS	S9n[        US   US   5        [        US   US   S-  5        [        R                  " [
        S
S9   [         R                  " XSS9  S S S 5        g ! , (       d  f       g = f)Nr  r  r  r~  r  r   r   r1   r  `alternative` must be 'less'...r   	ekki-ekki)ri   rb  r
   rP  r   r   r  s        rw   test_alternative#TestCorrSpearmanr2.test_alternative  s      ? oob&9CFHQK0CFA!q$9: oob)<CFHQK0CFHQK!O4]]:-NOOOB< POOs   B>>
Cr  r=  c                 x   / SQn/ SQnU[         R                  /-   nU[         R                  /-   n[        [        R                  " XE5      [         R                  [         R                  45        [        R                  " XESUS9n[        R                  " X#US9n[        Xg5        Sn[        R                  " [        US9   [        R                  " XESUS9  S S S 5        S	n[        R                  " [        US9   [        R                  " XES
US9  S S S 5        g ! , (       d  f       NI= f! , (       d  f       g = f)Nr  r  r   r   r  r  r   r   r   r   rM  )	r   rm   r	   ri   rb  r   rP  r   r   )	rn   r  r  r  x1nanx2nan
res_actualres_expectedr  s	            rw   test_alternative_nan_policy.TestCorrSpearmanr2.test_alternative_nan_policy  s     bffXbffX 	5??58266266:JK __Uf1<>
r;G
1 2]]:W5OOEW(35 6
 1]]:W5OOE[(35 65 65 65s    D:D+
D(+
D9r   N)r   r   r   r   r   r  r	  r  r  r  r  r"  r'  r-  r5  r:  rB  rF  rI  rN  rP  r  r  rV  r   r   rz   rw   r  r    s|    71@
1KN9
!P$$&$ 	$A=. [[],LM5 N5rz   r  c            	         Sn / SQn/ SQnSnU  H<  n[         R                  " XUS9n[        US   US   5        [        US   US   5        M>     / SQn/ S	QnSnU  H<  n[         R                  " XUS9n[        US   US   5        [        US   US   5        M>     / S
Qn/ SQnSnU  H<  n[         R                  " XUS9n[        US   US   5        [        US   US   5        M>     / SQn/ SQnSnU  H<  n[         R                  " XUS9n[        US   US   5        [        US   US   5        M>     [        R                  " S5      n[        R                  " S5      nSnU  H<  n[         R                  " XUS9n[        US   US   5        [        US   US   5        M>     US   nUS   US'   XbS'   SnU  H<  n[         R                  " XUS9n[        US   US   5        [        US   US   5        M>     US   nUS   US'   XbS'   SnU  H<  n[         R                  " XUS9n[        US   US   5        [        US   US   5        M>     [        R                  " S5      n[        R                  " S5      S S S2   nSnU  H<  n[         R                  " XUS9n[        US   US   5        [        US   US   5        M>     US   nUS   US'   XbS'   SnU  H<  n[         R                  " XUS9n[        US   US   5        [        US   US   5        M>     US   nUS   US'   XbS'   SnU  H<  n[         R                  " XUS9n[        US   US   5        [        US   US   5        M>     [        / SQ5      n[        / SQ5      nSn[        [         R                  " XSS9S   U5        Sn[        [         R                  " XS S9S   U5        US   US'   [        [        [         R                  XS!S"9  [        [        [         R                  XS#S"9  [        [        [         R                  XS$S9  / S%Qn/ S&QnS'n[         R                  " Xx5      n[        US   US   5        [        US   US   5        S(n	U  HC  n[         R                  " XxUS9n[        XY5        [        UR                  UR                  5        ME     U  H  n[        [         R                  " / S)Q/ S)QUS9[        R                  [        R                  45        [        [         R                  " / S*Q/ S)QUS9[        R                  [        R                  45        [        [         R                  " / S)Q/ S*QUS9[        R                  [        R                  45        M     [        [         R                  " / / 5      [        R                  [        R                  45        [        R                  R                  S+5        [        R
                  " [        R                  R                  SSS,S-9[        R                  R                  SSS,S-9/5      nS.S//S/S.//n
[        R                   " [        R"                  R%                  U
5      U5      nS0n[         R                  " US   US   5      n[        US   US   5        [        US   US   5        [        [         R                  " / S1Q/ S1QSS9S   S.5        [        [         R                  " / S1Q/ S1QS S9S   S25        [        R                  " S35      n[        R                  US4'   ['        [         R                  " X5      [        R                  [        R                  45        [)        [         R                  " XS5S69S7S8S99  [)        [         R                  " XS5S:S;9S<S8S99  [        [        [         R                  XS=S69  [        [        [         R                  XS>S69  [        R                  " S35      n[        R                  " S?5      n[        [        [         R                  X5        [         R                  " / / 5      u  p[        [        R                  U5        [        [        R                  U5        [         R                  " S/S/5      u  p[        [        R                  U5        [        [        R                  U5        [        R                  " S@[*        SA9n[        R,                  R/                  USB5      n[        R                  " S@[*        SA9n[        R0                  " USCS  US SC 45      n[3        [        R4                  " [         R                  " X5      S   5      5        g )DN)rE  rY  )r4   r1   r   r2   r5   r3   r6   r7   )r4   r1   r5   r2   r   r7   r6   r3   r  )variantr   r   )	r   r4   r1   r   r2   r5   r3   r6   r7   )	r4   r1   r   r5   r2   r   r7   r6   r3   )r4   r1   r   r2   r5   r3   r6   )r4   r1   r5   r2   r   r6   r3   )gJ$I¿gmK?)r1   r   r2   r5   r3   r6   r7   )r1   r5   r2   r   r7   r6   r3   )gJkaa?r   r\   )r   紞xO~>r1   )g?>?aV>r4   r5   )g}'}'?o&5>rb   )r>  rZ  )g?>r[  )g}'}'r\  )
r   r1   r1   r3   r3   r5   r5   r7   r8   r8   )
r   r1   r3   r3   r3   r3   r7   r7   r7   r\   gok|?rE  gffffff?rY  r  r  bananarmsr^   r1   r   r^   r1   r   r3   r6   r   r   )g}+޿g`=i?r'  r*  r+  r  r  r  r   r4  )g\zf?g^n)=r  g#q?r   r8   r   r   )r   g/>r  r  r  )r   r  )r   g&?r   r   r  r%  rZ  i  r  )ri   
kendalltaur
   r   r   r   r   r   r   r   r(  r*  rm   r  rn  r  r  r  r  r	   r   r  mamasked_greaterconcatenater   isfinite)variantsrp   rq   r  tauxr   rE  r  r  r,  r  taup_values                rw   test_kendalltaurk    sQ    H 	!A A HqT2CFHQK0CFHQK0  	$A#A HqT2CFHQK0CFHQK0  	AA /HqT2CFHQK0CFHQK0  	AA %HqT2CFHQK0CFHQK0  			"A
		"A )HqT2CFHQK0CFHQK0  	
!AQ4AaDaD 8HqT2CFHQK0CFHQK0  	
!AQ4AaDaD 8HqT2CFHQK0CFHQK0  			"A
		"ddA *HqT2CFHQK0CFHQK0  	
!AQ4AaDaD 9HqT2CFHQK0CFHQK0  	
!AQ4AaDaD 9HqT2CFHQK0CFHQK0  	,-A-.AH((s;A>IH((s;A>I Q4AaD*e..WE *e..XF *e..eD
 
B	B:H


2
"CA,A, +Jrt4C,S__cmm4  U%%iDIffbff%	'U%%iDIffbff%	'U%%iDIffbff%	'  !!"b)BFFBFF+;< IINN4
"))""q"<))""q"<> 	?A#J#JD
ryy!!$'+A<H


1Q41
&CA,A, ((IsKAN((IsKAN"$ 			#A66AaDu''-/?@E$$Qf='e5E$$Qf\R1?*e..I*e..J 			#A
		#A*e..5 ##B+LC!##QC!-LC! 			$e$A
Q%A
		$e$A
$%!ET(+,ABKK((-a012rz   c                     [         R                  R                  S5        [        SS5       H  n / n[        U 5       H  nX/U-  -  nM     [	        U5      n[         R                  R                  U5        [         R                  R                  U5        [        R                  " X5      n[        R                  " X5      n[        US   US   5        [        US   US   5        M     g )N*   r1   r\   r   r   )
r   r  rn  r  r&  shufflemstats_basicrb  ri   r
   )sr9  r  rE  r  r  s         rw   test_kendalltau_vs_mstats_basicrq    s    IINN21R[qAQJA G
		!
		!**10!!!'F1Ix{3F1Ix{3 rz   c                      / SQn [         R                  SSS/n[        R                  " XSS9n[        R                  " U SS  USS  5      n[	        UR
                  UR
                  SS9  g )	Nr0  333333@333333@r   r   r   r2  r3  )r   rm   ri   rb  r   r*  )rp   rq   r1r2s       rw   test_kendalltau_nan_2nd_argrw    s]    A	c3A			!6	2B			!AB%12	'BBLL",,U;rz   c                      SS K n U R                  S5        / SQnSnU R                  XS9nU R                  XS9n[        R                  " X45      n[        UR                  S5        [        UR                  SSS	9  g )
Nr   i_ r   r1   r2   r3   r4   r5   r6   i@ r~  g*8_2\S?gd`TR?gMb`?r3  )r  rn  choicesri   rb  r   r*  r)  )r  classes	n_samplesrp   rq   r   s         rw    test_kendalltau_gh18139_overflowr~    sn     
KK#GIw,Aw,A


1
 CCMM#89 CJJT2rz   c            	       p   \ rS rSrS rSr\R                  \R                  \R                  /r/ SQr	/ SQr
/ SQr/ SQr/ SQr/ S	Qr/ S
Qr/ SQrS r\" \" \\S/S-  5      5      \" \" \\" \5      S/S-  5      5      -   r\R.                  R1                  S\5      S 5       r\" \" \\	S/S-  5      5      \" \" \\" \	5      S/S-  5      5      -   r\R.                  R1                  S\5      S 5       r\" \" \\
S/S-  5      5      \" \" \\" \
5      S/S-  5      5      -   r\R.                  R1                  S\5      S 5       r\" \" \\S/S-  5      5      \" \" \\" \5      S/S-  5      5      -   r\R.                  R1                  S\5      S 5       r\" \" \\S/S-  5      5      \" \" \\" \5      S/S-  5      5      -   r \R.                  R1                  S\ 5      S 5       r!\" \" \\S/S-  5      5      \" \" \\" \5      S/S-  5      5      -   r"\R.                  R1                  S\"5      S 5       r#\" \" \\S/S-  5      5      \" \" \\" \5      S/S-  5      5      -   r$\R.                  R1                  S\$5      S 5       r%\" \" \\S/S-  5      5      \" \" \\" \5      S/S-  5      5      -   r&\R.                  R1                  S\&5      S 5       r'\" \" \\S/S-  5      5      \" \" \\" \5      S/S-  5      5      -   r(\R.                  R1                  S\(5      S 5       r)\" \" \S/S-  5      5      \" \" \S/S-  5      5      -   r*\R.                  R1                  S\*5      S 5       r+\R.                  R1                  SS5      \R.                  R1                  SS5      S  5       5       r,S!r-g")#TestKendallTauAlternativei  c                 0   / SQn/ SQn[         R                  " XSS9nUS   S:  d   e[         R                  " XSS9n[        US   US   5        [        US   SUS   S-  -
  5        [         R                  " XS	S9n[        US   US   5        [        US   US   S-  5        UR	                  5         [         R                  " XSS9nUS   S:  d   e[         R                  " XS	S9n[        US   US   5        [        US   SUS   S-  -
  5        [         R                  " XSS9n[        US   US   5        [        US   US   S-  5        [
        R                  " [        S
S9   [         R                  " XSS9  S S S 5        g ! , (       d  f       g = f)Nr  r  r|  r  r   r~  r   r1   r  rL  r   rM  )ri   rb  r   r   reverserP  r   r   r  s        rw   &test_kendalltau_alternative_asymptotic@TestKendallTauAlternative.test_kendalltau_alternative_asymptotic  s     ##BD{Q r6:SVXa[)AXa[1_ 56 r9=SVXa[)Aa0 	

 ##BD{Q r9=SVXa[)AXa[1_ 56 r6:SVXa[)Aa0]]:-NOR= POOs   (F
F)r~  r|  r  )r   r   r:   )r   RUUUU?ZUUUU?)g~?r  r  )?r   r  )ˮ[?r   r  )g?gSǌ?gSǌ?)g:
?g3
?g<t'.?)gN  A?gss?gYss?c                     U(       a  [         R                  " U5      * nUS-  n[        R                  " XSUS9nXV4n[	        Xx5        g )Nrb   r  rC  )r   rf   ri   rb  r   )	rn   rp   rq   r  revstat_expected
p_expectedr   rU  s	            rw   
exact_test$TestKendallTauAlternative.exact_test%  sB    AARMqGM$0*rz   Fr2   Tzalternative, p_expected, revc                 T    S/S/pT[         R                  nU R                  XEXXb5        g )Nr   r1   )r   rm   r  rn   r  r  r  rp   rq   r  s          rw   test_against_R_n1+TestKendallTauAlternative.test_against_R_n10  s&    sQC1kJrz   c                 <    SS/SS/pTSnU R                  XEXXb5        g )Nr   r1   r2   r3   g?r  r  s          rw   test_against_R_n2+TestKendallTauAlternative.test_against_R_n29  s&    1v1v1*kJrz   c                 <    / SQ/ SQpTSnU R                  XEXXb5        g )Nr  r   r  r  s          rw   test_against_R_c0+TestKendallTauAlternative.test_against_R_c0B  s    )1kJrz   c                 <    / SQ/ SQpTSnU R                  XEXXb5        g )Nr  )r   r1   r3   r2   gVUUUUU?r  r  s          rw   test_against_R_c1+TestKendallTauAlternative.test_against_R_c1K  s    \1*kJrz   c                 <    / SQ/ SQpTSnU R                  XEXXb5        g )Nr  )r   r4   r3   r1   r2   r   r  r  s          rw   test_against_R_no_correlation7TestKendallTauAlternative.test_against_R_no_correlationU  s    1kJrz   c                 <    / SQ/ SQpTSnU R                  XEXXb5        g )Nr   r1   r2   r3   r4   r5   r6   r7   )r7   r5   r   r2   r1   r4   r3   r6   r   r  r  s          rw   test_against_R_no_correlationb8TestKendallTauAlternative.test_against_R_no_correlationb_  s    ')A1kJrz   c                 >    / SQn/ SQnSnU R                  XEXXb5        g )N)	g333333F@g33333F@g33333D@gfffffJ@gYF@gF@gYI@gF@gN@)	g@@r<   rO   @r   g@ffffff@r  gqq?r  r  s          rw   test_against_R_lt_171/TestKendallTauAlternative.test_against_R_lt_171h  s$     C9*kJrz   c                     [         R                  R                  S5        [         R                  R                  S5      n[         R                  R                  S5      nSnU R	                  XEXXb5        g )Nr   r  gUm*,r   r  rn  r|  r  r  s          rw   test_against_R_lt_171b0TestKendallTauAlternative.test_against_R_lt_171bu  sK    
		qIINN3IINN3,kJrz   c                     [         R                  R                  S5        [         R                  R                  S5      n[         R                  R                  S5      nSnU R	                  XEXXb5        g )Nr      gH4?r  r  s          rw   test_against_R_lt_171c0TestKendallTauAlternative.test_against_R_lt_171c  sK    
		qIINN3IINN3*kJrz   zalternative, revc                 \   [         R                  R                  S5        [         R                  R                  S5      n[         R                  R                  S5      n[        R
                  " X4SUS9n[        R
                  " X4SUS9n[        US   US   5        [        US   US   SS9  g )	Nr   i  r  rC  r  r   r  r  )r   r  rn  r|  ri   rb  r   r   )rn   r  r  rp   rq   res0r  s          rw   test_gt_171%TestKendallTauAlternative.test_gt_171  s    
		qIINN3IINN3W,79\,79T!Wd1g&Qat4rz   r  )r  r  r  r=  c           	      ~   / SQn/ SQnU[         R                  /-   nU[         R                  /-   n[        R                  " XVXS9n[         R                  [         R                  4n[	        Xx5        [        R                  " XVSXS9n[        R                  " X4UUS9n[	        Xx5        Sn	[
        R                  " [        U	S9   [        R                  " XVSXS9  S S S 5        S	n	[
        R                  " [        U	S9   [        R                  " XVS
XS9  S S S 5        g ! , (       d  f       NI= f! , (       d  f       g = f)Nr  r4   r5   r6   r7   r8   rC  r   )r   r  r  r   r   r   r   rM  )r   rm   ri   rb  r   rP  r   r   )
rn   r  r  r  r  rR  rS  rT  rU  r  s
             rw   ry  )TestKendallTauAlternative.test_nan_policy  s    bffXbffX %%e-3N
'
1 %%ev-3N
''v4?A
1 2]]:W5Ug$*E 6
 1]]:W5Uk$*E 65 65 65s   D=D.
D+.
D<r   N).r   r   r   r   r  alternativesr   rm   p_n1p_n2p_c0p_c1p_no_correlationp_no_correlationb
p_n_lt_171p_n_lt_171bp_n_lt_171cr  r&  r   reversed	case_R_n1rP  r  r  r  	case_R_n2r  	case_R_c0r  	case_R_c1r  case_R_no_corrr  case_no_cor_br  case_R_lt_171r  case_R_lt_171br  case_R_lt_171cr  case_gt_171r  ry  r   r   rz   rw   r  r    s   '>h 4LFFBFFBFF#DD0D>D<=DJCKGK+ c,ugai89L(4.4&(CDEI [[;YGK HK
 c,ugai89L(4.4&(CDEI [[;YGK HK
 c,ugai89L(4.4&(CDEI [[;YGK HK
 c,ugai89L(4.4&(CDEI [[;YGK HK
 3|-=wqyIJSx8H/I"&+ ,,N [[;^LK MK
 #l,=wqyIJCh7H.I!%q* ++M [[;]KK LK
 #lJ	BCChz.BTF1HMNOM [[;]KK LK 3|[5'!)DESx/D"&+ ,,N [[;^LK MK 3|[5'!)DESx/D"&+ ,,N [[;^LK MK L5'!)45L4&(345K [[/=	5 >	5 [[X'>?[[],LME N @Erz   r  c                     / SQn / SQn[         R                  " X5      u  p#[        US5        [        [        R
                  U5        [         R                  " XSS9u  p#[        US5        [        [        R
                  U5        [         R                  " XS S9u  p#[        US	5        [        [        R
                  U5        [         R                  " X5      nS
n[        XE5        [        UR                  UR                  5        [         R                  " XS S9u  p#[        US5        [        [        R
                  U5        [         R                  " XS S9u  p#[        US5        [        [        R
                  U5        [         R                  " XS SS9u  p#[        US5        [        [        R
                  U5        [         R                  " XS SS9u  p#[        US5        [        [        R
                  U5        [         R                  " XSS9u  p#[        US5        [        [        R
                  U5        [         R                  " XSS S9u  p#[        US	5        [        [        R
                  U5        [         R                  " XSS S9u  p#[        US	5        [        [        R
                  U5        [         R                  " [        R                  " U [        R                  S9U5      u  p#[        US5        [         R                  " [        R                  " U [        R                  S9U5      u  p#[        US5        [         R                  " [        R                  " U [        R                  S9[        R                  " U[        R                  S95      u  p#[        US5        [         R                  " / / 5      u  p#[        [        R
                  U5        [        [        R
                  U5        [         R                  " S/S/5      u  p#[        [        R
                  U5        [        [        R
                  U5        [        [        [         R                  SS// SQ5        [        [        [         R                  SS/SS/S/5        / SQn SSSS[        R
                  /n[         R                  " X5      u  p#[        US5        SS[        R
                  SS/n [         R                  " X5      u  p#[        US5        / SQn SS S!S[        R
                  /n[         R                  " X5      u  p#[        US5        S"S#[        R
                  S"S#/n [         R                  " X5      u  p#[        US5        / S$Qn / S%Qn[         R                  " X5      u  p#[        US&5        S"S#[        R
                  S"[        R
                  /n [         R                  " X5      u  p#[        US&5        [        R
                  S S![        R
                  [        R
                  /n[         R                  " X5      u  p#[        US&5        g )'Nr_  r`  gs$F)additivegROoc                     gNr   r   rp   s    rw   <lambda>"test_weightedtau.<locals>.<lambda>  s    Qrz   )weigherra  r'  )rankgڿgn)r  r  g @ڿg[đ(gIکnTc                     gr  r   r  s    rw   r  r        rz   )r  r  c                     gr  r   r  s    rw   r  r    r  rz   rZ  r   r   r   r   r1   r3   r6   r^   r1   )      (@rm  r   r  rm  r   r   r   r  rm  )r  rm  r   r  r   )r   r   r   r   r   gt34+)ri   weightedtaur
   r   r   rm   r   r(  r*  rf   r   int16r   r   )rp   rq   ri  rj  r   r,  s         rw   test_weightedtaur    s   AA$$Q*LC12!$$QE:LC12!$$Q;?LC12! 

A
!C*J(#--0 $$Q5LC01!$$Q5LC01!$$QuELC12!$$QuELC12!$$Q6LC12!$$QkJLC12!$$QkJLC12!$$RZZ%DaHLC12$$RZZ%BAFLC12$$RZZ%D%'ZZ%DFLC12$$R,LC!$$aS1#.LC!*e//!QC*e//!Q!Q!EA	
Aq!RVVA$$Q*LC12	QAA$$Q*LC12#A	c3RVV$A$$Q*LC12	sBFFD#&A$$Q*LC12#A!A$$Q*LC01	sBFFD"&&)A$$Q*LC01	c266266*A$$Q*LC01rz   c                      [         R                  " S/S/5        [         R                  " S/S/5        [         R                  " [        R                  /S/5        g )Nr   r   4   )ri   r  r   rm   r   rz   rw   test_segfault_issue_9710r    sD     
qcC5!	qcC5!	rvvh%rz   c                  &   Sn [         R                  " U S-   5      R                  [        5      n[         R                  " U S-   5      R                  [        5      n[         R                  US'   [
        R                  " XSSS9u  p4[        US5        g )N   r   rb   r  r   )r  r   r   )r   r   r  r  rm   ri   rb  r   )r  rp   rq   _r  s        rw   test_kendall_tau_larger    sn    A
		!a%&A
		!a%&AFFAbEqGGGAsrz   c            
      |   S n S n[         R                  R                  S5        [        SS5       GH  n/ n[        U5       H  nX4/U-  -  nM     [	        U5      n[         R                  R                  U5        [         R                  R                  U5        [         R                  " [        U5      [         R                  S9n[        S5       Hb  nS H:  nU " X5XaU5      n	[        R                  " X5XaU5      R                  n
[        X5        M<     [         R                  R                  U5        Md     GM	     g )	Nc                 P   S=n=n=n=p[        [        [        U 5      5      [        [        U 5      5      5       H  u  pU(       a  U" X*   5      U" X+   5      -   OU" X*   5      U" X+   5      -  nX\-  nX
   X   :X  a  X-  nX   X   :X  a  X-  n	X
   X   :  a
  X   X   :  d  X
   X   :  a  X   X   :  a  Xl-  nM  X
   X   :  a
  X   X   :  d  X
   X   :  d  M  X   X   :  d  M  X|-  nM     Xg-
  [        R                  " XX-
  5      -  [        R                  " XY-
  5      -  $ )Nr   )r   r  lenr   r6  )rp   rq   r  r  addtotconcdiscuvr  r  ws                rw   wkq*test_weightedtau_vs_quadratic.<locals>.wkq+  s$   $%%%d%T%AeCFmU3q6];FQ7: 747#33TW%(88 HCtqt|tqt|tad{qtad{adQTkadQTk	qtqt	 < rwwsw//"''#'2BBBrz   c                     SU S-   -  $ )Nr   r   r   r  s    rw   r  .test_weightedtau_vs_quadratic.<locals>.weigher;  s    QU|rz   rm  r2   r\   rZ  r1   r`   )r   r  rn  r  r&  rn  r   r  intpri   r  r*  r
   )r  r  rp  r9  r  rE  r  r  r  r  r  s              rw   test_weightedtau_vs_quadraticr  )  s    C  IINN21R[qAQJA G
		!
		!yyQrww/qA$qTC8**1DNN#H5 %
 IId#  rz   c                        \ rS rSrS rS rSrg)TestFindRepeatsiR  c                     / SQnSn[         R                  " US9   [        R                  " U5      u  p4S S S 5        [	        W/ SQ5        [	        W/ SQ5        g ! , (       d  f       N+= f)N)r   r1   r2   r3   r   r1   r2   r3   r   r1   r4   +`scipy.stats.find_repeats` is deprecated...r   r  )r2   r2   r1   r1   rP  deprecated_callri   find_repeatsr	   )rn   r9  r  r   numss        rw   rF  TestFindRepeats.test_basicT  sN    -?##'2**1-IC 33-4. 32s   A
A'c                     / SQ/ 4 HR  nSn[         R                  " US9   [        R                  " U5      u  p4S S S 5        [	        W/ 5        [	        W/ 5        MT     g ! , (       d  f       N+= f)N)r\   r  2      (   r  r   r  )rn   r9  r  repeatedcountss        rw   test_empty_result!TestFindRepeats.test_empty_result\  sW    &+ACG''g6#(#5#5a#8  7x,vr* ,66s   A
A,	r   N)r   r   r   r   rF  r  r   r   rz   rw   r  r  R  s    /+rz   r  c                   @   \ rS rSrS rS rS rS rS rS r	S r
\R                  R                  S	5      S
 5       r\R                  R                  S	5      S 5       r\R                  R                  S	5      S 5       rS rS rS rS rS rS rS rS rS rS rSrg)TestRegressionif  c                    [         R                  " S5      R                  S5      nSn[        R                  " US9   [
        R                  " U5        S S S 5        [
        R                  " US   US   5        g ! , (       d  f       N,= f)Nr  r1   r\   zInference of the two sets...r   r   r   )r   r   rk   rP  r  ri   
linregressrn   rp   r  s      rw   test_one_arg_deprecation'TestRegression.test_one_arg_deprecationh  sa    IIbM!!'*0##'2Q 31qt$ 32s   A99
Bc                     [         R                  " [        [        5      n[	        UR
                  S5        [	        UR                  S5        [	        UR                  S5        [	        UR                  S5        g )Nir   r   )	ri   r  rg   r   r   	interceptrvaluestderrintercept_stderrrn   r  s     rw   test_linregressBIGX"TestRegression.test_linregressBIGXo  sR    !!!S)F,,h7FMM3/ 	FMM3/F33S9rz   c                     [         R                  " [        [        5      n[        UR                  S5        [        UR
                  S5        [        UR                  S5        [        UR                  S5        g )Nr   r   )ri   r  rg   r   r  r  r  r  r  s     rw   test_regressXXTestRegression.test_regressXXy  sR    
 !!!Q'F,,c2FMM3/FMM3/F33S9rz   c                     [         R                  " [        [        5      n[	        UR
                  S5        [	        UR                  S5        g )Nr   )ri   r  rg   ZEROr   r  r  r  s     rw   test_regressZEROX TestRegression.test_regressZEROX  s4    
 !!!T*F,,c2FMM3/rz   c                 Z   [         R                  " SSS5      nS[         R                  " SSS5      -  S-   nU[         R                  " [         R                  " SSS5      5      -  n[        R                  " X5      n[
        n[        [        X45      5        [        UR                  S5        g )Nr   r  皙?r\   r  穷4_Qc?)
r   linspacesinri   r  r"   r   
isinstancer   r  )rn   rp   rq   r  lrs        rw   test_regress_simple"TestRegression.test_regress_simple  s    KK3$"++ac**R/	RVVBKK2s+,,!!!'
6&'FMM+@Arz   c                    [         R                  " SSS5      nS[         R                  " SSS5      -  S-   nU[         R                  " [         R                  " SSS5      5      -  n[        R                  " [
        SS9   [        R                  " XSS	9  S S S 5        [        R                  " XS
S	9n[        R                  " XSS	9n[        UR                  SUR                  S-  -
  5        [        R                  " XSS	9n[        UR                  UR                  S-  5        UR                  UR                  s=:X  a  UR                  :X  d   e   eg ! , (       d  f       N= f)Nr   r  r  r\   r  rL  r   rM  r  r|  r~  r   r1   r  )r   r!  r"  rP  r   r   ri   r  r   r)  r  )rn   rp   rq   r  r  r  s         rw   test_regress_alternative'TestRegression.test_regress_alternative  s   KK3$"++ac**R/	RVVBKK2s+,,]]:-NOQ{; P +> &9Q$++/%:; )<T[[1_5{{dkk8T[[88888 POs   ?E
E$c                 n   / SQn/ SQn[         R                  " XSS9n[        UR                  S5        [        UR                  S5        [        UR
                  [        R                  " S5      5        [        UR                  S5        [        UR                  S	5        [        UR                  S
5        g )N)
                              )
?   Q   8   [   /   9   rK   H   >   r  r|  r  gؗh?gJK@:Cgag?g->g5ՒO?g]؊E @)ri   r  r   sloper  r  r   r6  r)  r  r  )rn   rp   rq   r   s       rw   test_regress_against_R%TestRegression.test_regress_against_R  s     ?4q=		?3'89

BGGM$:;

$56

O4,,o>rz   ignore::DeprecationWarningc                    [         R                  " SSS5      nS[         R                  " SSS5      -  S-   nU[         R                  " [         R                  " SSS5      5      -  n[         R                  " X45      n[        R
                  " U5      n[        UR                  S5        [        UR                  S5        g )Nr   r  r  r\   r  r   8?)	r   r!  r"  vstackri   r  r   r  r  )rn   rp   rq   rowsr  s        rw   test_regress_simple_onearg_rows.TestRegression.test_regress_simple_onearg_rows  s     KK3$"++ac**R/	RVVBKK2s+,,yy! !!$'FMM+@AF335JKrz   c                    [         R                  " SSS5      nS[         R                  " SSS5      -  S-   nU[         R                  " [         R                  " SSS5      5      -  n[         R                  " [         R                  " US5      [         R                  " US5      45      n[
        R                  " U5      n[        UR                  S5        [        UR                  S5        g )	Nr   r  r  r\   r  r   r   rB  )
r   r!  r"  hstackexpand_dimsri   r  r   r  r  )rn   rp   rq   columnsr  s        rw   test_regress_simple_onearg_cols.TestRegression.test_regress_simple_onearg_cols  s    KK3$"++ac**R/	RVVBKK2s+,,))R^^Aq12>>!Q3GHI!!'*FMM+@AF335JKrz   c                 j    [        [        [        R                  [        R
                  " S5      5        g )Nr  )r   r   ri   r  r   r  rh  s    rw   test_regress_shape_error'TestRegression.test_regress_shape_error  s     	j%"2"2BGGFODrz   c                    [         R                  " S5      n[         R                  " SS5      nUSS/==   S-  ss'   USS/==   S-  ss'   [        R                  " X5      nS nU" UR                  S	5        U" UR
                  S
5        U" UR                  S5        U" UR                  S5        U" UR                  S5        U" UR                  S5        g )Nr]   r4   r   r   r   rb   c                     [        XSS9$ )NrZ   r  )r   rp   rq   s     rw   	assert_ae1TestRegression.test_linregress.<locals>.assert_ae  s    &qR88rz   r   rO   gePUn?g.bt>gڽE?gʺL7?)
r   r   ri   r  r=  r  r  r)  r  r  )rn   rp   rq   r  rU  s        rw   test_linregressTestRegression.test_linregress  s    IIbMIIa	A+!	A+!!!!'	9&,,$&""C(&--!12&--1&--!56&))+>?rz   c                    Su  p[         R                  " USU-  U5      n[         R                  " SU-  X5      n[        R                  " X45      n[	        UR
                  S:  5        [        UR
                  S5        [	        [         R                  " UR                  5      (       + 5        [	        [         R                  " UR                  5      (       + 5        g )N)gJr 11順 r1   rb   )
r   r!  ri   r  r   r  r   r  r  r  )rn   r9  r  rp   rq   r  s         rw    test_regress_simple_negative_cor/TestRegression.test_regress_simple_negative_cor	  s     KK1q5!$KKAq$!!!' 	#$FMM2. 	BHHV]]++,BHHV44556rz   c                 j   [         R                  " SSS5      nS[         R                  " SSS5      -  S-   nU[         R                  " [         R                  " SSS5      5      -  n[        R                  " X5      n[
        n[        [        X45      5        Sn[        X55        S[        U5      ;   d   eg )Nr   r  r  r\   r  )r=  r  r  r)  r  r  )
r   r!  r"  ri   r  r"   r   r#  r   dir)rn   rp   rq   r  r$  r,  s         rw   !test_linregress_result_attributes0TestRegression.test_linregress_result_attributes	  s    KK3$"++ac**R/	RVVBKK2s+,,!!!' 
6&' J
F/!S[000rz   c                    [         R                  " S5      n[         R                  " SS5      n[        R                  " X5      n[	        UR
                  S5        [	        UR                  S5        [	        UR                  S5        g )Nr1   r2   r4   r   )r   r   ri   r  r   r)  r  r  rn   rp   rq   r  s       rw   test_regress_two_inputs&TestRegression.test_regress_two_inputs&	  s^    IIaLIIaO!!!' 	FMM3/ 	FMM3/F33S9rz   c                    [         R                  " S5      n[         R                  " S5      n[        R                  " X5      n[        UR                  S5        [        UR                  S5        [        UR                  S5        g )Nr1   r   r   )	r   r   r  ri   r  r   r)  r  r  rb  s       rw   'test_regress_two_inputs_horizontal_line6TestRegression.test_regress_two_inputs_horizontal_line3	  s\    IIaLGGAJ!!!' 	FMM3/ 	FMM3/F33S9rz   c                 N   / SQn/ SQn[         R                  " X5      n[        UR                  S5        [        UR                  S5        [        UR
                  S-  S5        [        UR                  S5        [        UR                  S5        [        UR                  S	5        g )
N)$r  gfffffu@ǧ]@g̤@333333$@g     Pl@gfffff҄@gfffff"@g	|@g     H@gq@皙?333333?g     <@g33333ׄ@g      u@g     {@g333333'@g     `@33333l@gfffff@g̼@g^@r4  r4  gffffff@g1u@g@g     8@g     X@g333333&@g33333]@gfffffl@g@fffff|@r:   )$r1  g,u@gfffff]@     @r  rl  g     @     4@g|@33333W@gy@r4  r1  gP@gfffff@4u@rm  g%@gm@gl@g     0@gfffffƋ@gfffff]@r4  rk  gl@rq  rn  ro  rp  gffffff$@gffffff]@g̜l@g33333@g33333|@r  g?g!пr1   gpX?r   gh-h*<?gg?)	ri   r  r   r=  r  r  r)  r  r  rb  s       rw   test_nist_norrisTestRegression.test_nist_norris@	  s    77 !!!'FLL*:;F,,.@AFMM1,.?@FMM3/FMM+;<F335EFrz   c                    [         R                  " SSS5      nS[         R                  " SSS5      -  S-   nU[         R                  " [         R                  " SSS5      5      -  n[        R                  " X5      n[         R
                  " XS5      n[        UR                  US   5        [        UR                  US   5        g )Nr   r  r  r\   r  r   )	r   r!  r"  ri   r  polyfitr   r=  r  )rn   rp   rq   r  polys        rw   test_compare_to_polyfit&TestRegression.test_compare_to_polyfit[	  s    KK3$"++ac**R/	RVVBKK2s+,,!!!'zz!" 	FLL$q'2F,,d1g6rz   c                 D    [        [        [        R                  / / 5        g r  )r   r   ri   r  rh  s    rw   test_empty_inputTestRegression.test_empty_inputg	  s    j%"2"2B;rz   c                    [         R                  " S5      n[         R                  US'   [         R                  " SS9   [        R
                  " X5      nS S S 5        [        n[        [        WU5      5        [        U[         R                  4S-  5        [        UR                  [         R                  5        g ! , (       d  f       Nl= f)Nr   r8   ignoreinvalidr4   )r   r   rm   errstateri   r  r"   r   r#  r	   r   r  )rn   rp   r  r$  s       rw   test_nan_inputTestRegression.test_nan_inputj	  s    IIcNvv![[*%%a+F + 
62&'6BFF9Q;/V,,bff5 +*s   B;;
C	c                     [         R                  " S5      n[         R                  R                  S5      nSn[        [        US9   [
        R                  " X5        S S S 5        g ! , (       d  f       g = f)Nr\   z$Cannot calculate a linear regressionr   )r   rH  r  r   r   ri   r  rn   rp   rq   r   s       rw   test_identical_xTestRegression.test_identical_xw	  sL    HHRLIIR 4:S1Q" 211s   A&&
A4r   N)r   r   r   r   r  r  r  r  r%  r(  r>  rP  r  filterwarningsrE  rK  rN  rW  r[  r_  rc  rf  rr  rw  rz  r  r  r   r   rz   rw   r  r  f  s    %:
:*0	B9*?* [[ <=
L >
L [[ <=L >L [[ <=E >E
@,7$1 ::G6
7<6#rz   r  c                     [         R                  " / SQ5      u  pp#[        U S5        [        US5        Sn[        R                  " [
        US9   [         R                  " / SQSS9  S S S 5        [         R                  " / SQSS9u  pp#[        U S5        [        US5        / S	Qn/ S
Qn[         R                  " XeSSS9u  pp#[        U S5        [        US5        [        USSS9  [        USSS9  [         R                  " XeSSS9u  pp#[        U S5        [        US5        [        USSS9  [        USSS9  g ! , (       d  f       N= f)Nr   r   r   r:   zHmethod must be either 'joint' or 'separate'.'joint_separate' is invalid.r   joint_separater  jointr   )r   r1   r2   r3   r\   r^      )r8   r     r  -   7   N   gQ?separater3   r   gQ@r1   rS  gGz@r   )ri   theilslopesr   rP  r   r   )r=  r  lowerupperr   rp   rq   s          rw   test_theilslopesr  	  s.   %*%6%6w%?"Ees#	3'*C	z	-),<= 
. &+%6%6y>E&G"Ees#	3' 	!A#A%*%6%6qT>H&J"Eeq!	3'tQ/tQ/%*%6%6qT>E&G"Eeq!	3'tQ/tQ// 
.	-s   D88
Ec                     / SQn [         R                  " U SS9u  pp4[        U[        R                  " / SQ5      5        [         R                  " U SSS9u  pp4[        US:H  5        Sn[         R                  " U SSS9n[        Xe5        g )	Nr   r3   r1   r   r2   r   r3   numbins)r1  r   rO   r   )r;   r4   )r  defaultreallimitsr2   )cumcountr   binsizeextrapoints)ri   cumfreqr   r   r   r   r   )rp   cumfreqslowlimr  r  r,  r   s          rw   test_cumfreqr  	  sy    A-2]]1a-H*Hgh1A(BC-2]]	1.2*HgK1 FJ
--1
AC(rz   c                      [         R                  " / SQ5      n [        R                  " U SS9u  pp4[	        U[        / SQ5      5        Sn[        R                  " U SS9n[        Xe5        [        R                  " / SQSS9u  prp4[	        X5        g )Nr  r3   r  )r:   K}\UU?r  r  )	frequencyr   r  r  )r   r   ri   relfreqr   r   )r9  relfreqsr  r  r  r,  r   	relfreqs2s           rw   test_relfreqr  	  s~    
#$A-2]]1a-H*Hgh#$MNP GJ
--1
%C( /4mm<NDE/G+Iwh2rz   c                   D    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
rg)TestScoreatpercentilei	  c                 :    / SQU l         / SQU l        / SQU l        g )N)r2   r3   r4   r\   rc   r5   )r2   rQ  r7   r6   r3   r1   r   )r1  r3   r4   r\   rc   r  r  r   a1a2a3rh  s    rw   setup_method"TestScoreatpercentile.setup_method	  s    *,1rz   c                     [        S5      S-  n[        [        R                  " US5      S5        [        [        R                  " US5      S5        [        [        R                  " US5      S5        g )	Nr7   r:   r   r   r  r=   r         ?)r   r   ri   scoreatpercentileru  s     rw   rF   TestScoreatpercentile.test_basic	  sT    1IOU,,Q2B7U,,Q4c:U,,Q3T:rz   c           	      *   [         R                  n[        U" [        [	        S5      5      S5      S5        [        U" [        [	        S5      5      SS5      S5        [        U" [        [	        S5      5      SSS9S5        [        U" [
        R                  " / SQ5      SS	5      S
5        [        U" [
        R                  " / SQ5      SS5      S5        [        U" [        [	        S5      5      SSS9S5        [        U" [        [	        S5      5      SSSS9S5        [        U" [        [	        S5      5      SSSS9S5        [        U" [
        R                  " / SQ5      SS	SS9S
5        [        U" [
        R                  " / SQ5      SSSS9S5        g )Nr\   r   r>   r1   r6   r  r   r7   )limitr   r\   r  r\   r  r  r   r\   r?   fractioninterpolation_methodr  r  ri   r  r   r&  r  r   r   rn   scoreatpercs     rw   test_fraction#TestScoreatpercentile.test_fraction	  sP   -- 	[eBi"5s;[eBi"e<cB[eCj!12VDcJ[+!6HErJ[+!6FCSI 	[eBi":V	[eBi"F6@B	 	[eCj!12V6@B	 	[+!6I6@B	 	[+!6F6@B	rz   c           	      $   [         R                  n[        U" [        [	        S5      5      SSS9S5        [        U" [        [	        S5      5      SSS9S5        [        U" [        [	        S5      5      SSSS9S5        [        U" [        [	        S5      5      SSSS	9S5        [        U" [        [	        S
5      5      SSSS9S5        [        U" [        [	        S
5      5      SSSS9S5        [        U" [
        R                  " / SQ5      SSSS9S5        [        U" [
        R                  " / SQ5      SSSS	9S
5        [        U" [
        R                  " / SQ5      SSSS9S5        [        U" [
        R                  " / SQ5      SSSS	9S5        g )Nr\   r   r  r  r3   higherr4   r  r  r  r  r  r  r  r   r  r  s     rw   test_lower_higher'TestScoreatpercentile.test_lower_higher	  s~   -- 	[eBi"6=?@A	C[eBi"6>@AB	D[eBi"e6=?@A	C[eBi"E6>@AB	D[eCj!12u6=?@A	C[eCj!12u6>@AB	D[,!7Y6=?@B	D[,!796>@AD	F[,!7W6=?@A	C[,!776>@AC	Erz   c           	      .   [        S5      S-  n[        R                  " / SQ5      n[        R                  " U/ SQ5      n[        X25        [        [        U[        R                  5      5        [        [        R                  " U[        R                  " / SQ5      5      U5        [        R                  " [        R                   " S5      R                  S5      [        R                  " / SQ5      SS	9n[        / S
Q/ SQ/ SQ/ SQ/5      n[        XE5        g )Nr7   r:   )r   r=   r  )r   r  r   r^   r2   r3   )r   r   r  r  r   rV   )r   r3   r7   )Q?gQ@g(\ @r2   r6   r]   )
r   r   r   ri   r  r   r   r#  ndarrayrk   )rn   rp   r  r   r  	expected2s         rw   test_sequence_per'TestScoreatpercentile.test_sequence_per	  s    1IO88N+%%a6&
3

+,//288L3IJ 	" &&ryy}'<'<U'C')xx0@'AK9-%%' (	 	(rz   c                    [         R                  n[        S5      R                  SS5      n[	        U" US5      / SQ5        / SQ/ SQ/ SQ/n[	        U" USS	S
9U5        / SQ/ SQ/ SQ/n[	        U" USSS
9U5        [        / SQ/ SQ/ SQ/ SQ/ SQ/5      n[         R                  " US5      n[	        UR                  S5        [	        US5        [         R                  " USS	S
9n[	        UR                  S5        [	        U/ SQ5        g )Nr^   r2   r3   )r  r   r  )g      @r?         &@)r1   r2   r3   r4   r3   r4   r5   r6   )r7   r8   r\   r]   r   rV   )      ?g      @g     !@)r;   r?         #@r  r   r   r   r   )r3   r3   r2   r   r   r   r2   )ri   r  r   rk   r   r   r  )rn   r  rp   r0ru  scores         rw   	test_axisTestScoreatpercentile.test_axis
  s    --2Jq!$[M24EFL.9[M:B? /:>[M:B?9	 
 ''2.U[["%UC ''2A6U[[$'UI&rz   c                     [        [        [        R                  SS/SSS9  [        [        [        R                  S/S5        [        [        [        R                  S/S5        g )Nr   r1   r7  r   r  e   rb   )r   r   ri   r  rh  s    rw   test_exception$TestScoreatpercentile.test_exception)
  sK    j%"9"9Aq62+3	5j%"9"9A3Dj%"9"9A3Crz   c                 n   [        [        R                  " / S5      [        R                  5        [        [        R                  " [        R
                  " / / /5      S5      [        R                  5        [        [        R                  " / SS/5      [        R                  [        R                  /5        g )Nr   c   )r   ri   r  r   rm   r   rh  s    rw   
test_empty TestScoreatpercentile.test_empty/
  sm    U,,R4bff=U,,RXXr2h-?DbffMU,,R"b:RVVRVV<LMrz   r  N)r   r   r   r   r  rF  r  r  r  r  r  r  r   r   rz   rw   r  r  	  s-    2
;4E2)$'0DNrz   r  c            
          \ rS rSrS rS rS rS r\R                  R                  S\R                  " SS5      5      S	 5       rS
 rS r\R                  R                  S/ SQS\R                   SSSS// SQS\R                   SS//5      \R                  R                  SSS/5      S 5       5       r\R                  R                  S\R                  " SS5      5      \R$                  4S j5       rS rS r\R                  R                  SSS/5      S 5       rS r\R                  R1                  S5      \R                  R                  S \R2                  " S!5      \R2                  " S"5      /5      S# 5       5       rS$ rS%rg&)'TestModei5
  c                 "   [         R                  " [        [        S9   [        R
                  " / 5      u  pS S S 5        [        W[        R                  " / 5      5        [        W[        R                  " / 5      5        g ! , (       d  f       NO= fNr   )	rP  rQ  r   r   ri   moder   r   r   rn   valsr  s      rw   r  TestMode.test_empty7
  sU    \\,4IJ ::b>LD KT288B<(VRXXb\* KJs   B  
Bc                     [         R                  " S5      u  p[        U[        R                  " S/5      5        [        U[        R                  " S/5      5        g )Nr   r   )ri   r  r   r   r   r  s      rw   rd  TestMode.test_scalar=
  s9    zz"~T288RD>*VRXXqc]+rz   c                 t    / SQn[         R                  " U5      n[        US   S5        [        US   S5        g )Nr2   r4   r   r\      r2   r1   r5   r7   r5   r\   r5   r   r5   r   r2   ri   r  r   )rn   data1r  s      rw   rF  TestMode.test_basicB
  s1    7zz% T!Wa T!Wa rz   c           
         / SQn/ SQn/ SQn/ SQn/ SQn[         R                  " XX4U/5      n[        R                  " US SS9n[	        US   [         R                  " S	//5      5        [	        US
   [         R                  " S//5      5        [        R                  " USSS9n[	        US   [         R                  " / SQ/5      5        [	        US
   [         R                  " / SQ/5      5        [        R                  " US
SS9n[	        US   [         R                  " S/S/S/S	/S	//5      5        [	        US
   [         R                  " S/S/S/S/S//5      5        g )N)r\   r\   r  r  )r\   r\   r\   r\   )r  r\   r  r  )r  r  r  r  )r  r  r  r  TrW   keepdimsr   r  r   r7   )r\   r\   r  r  )r1   r2   r2   r1   r\   r  r1   r3   r2   )r   r   ri   r  r   )rn   r  data2data3data4data5arrr  s           rw   	test_axesTestMode.test_axesH
  s'        hheE:;zz#D48T!Wbhhv./T!Wbhhuo.zz#A5T!Wbhh(8'9:;T!Wbhh~67zz#A5T!WbhhrdRD2$'EFGT!WbhhaS1#sQC'@ABrz   rW   r   c                 .   [         R                  R                  S5        [         R                  R                  SSSS5      n[        R
                  " X"R                  U-   S9n[        R
                  " X!S9n[         R                  R                  X45        g )N:r\   r]   r^   r_   rV   )	r   r  rn  r|  ri   r  ndimr  r	   )rn   rW   r9  r  r  s        rw   test_negative_axes_gh_15375$TestMode.test_negative_axes_gh_15375\
  s`    
		y!IINN2r2r*zz!&&+.zz!'


%%d1rz   c                    / SQn/ n[         R                  " U5      nSn[        X45        [        R                  " [
        [        S9   [         R                  " U5      nS S S 5        [        WU5        g ! , (       d  f       N= f)Nr  )r  countr   )ri   r  r   rP  rQ  r   r   )rn   r  r  r  r,  actual2s         rw   test_mode_result_attributes$TestMode.test_mode_result_attributesd
  s_    7E"&
F/\\,4IJjj'G KGZ0 KJs   A33
Bc                 <   S[         R                  SSSSSSSSSSS/n[        R                  " U5      n[	        US	5        [        R                  " US
S9n[	        US	5        [        [        [        R                  USS9  [        [        [        R                  USS9  g )Nr2   r4   r   r\   r  r1   r5   r7   )r5   r2   r   r   r   r   )r   rm   ri   r  r   r   r   )rn   r  r  s      rw   test_mode_nanTestMode.test_mode_nann
  s|    BFFAq"b!Q1aQ?E"VV$Ef5VV$j%**eHj%**eIrz   data)r2   r4   r   r   r2   r2   r4   r   )r2   r4   r   r  FTc                     [         R                  " USUS9nU(       a  [        US   S   S5        g [        US   S5        g )Nr   )r   r  r   r   r  )rn   r  r  r  s       rw   test_smallest_equalTestMode.test_smallest_equalx
  s9     DVhG1q)A&rz   rc   c                    [         R                  R                  S5      nUR                  SS9R	                  U5      n[
        R                  " XASS9n[        UR                  5      nUR                  U5        [         R                  R                  UR                  R                  U5        [         R                  R                  UR                  R                  U5        g )Nr  r2   r3   r4   r  Fr  )r   r  r  uniformr  ri   r  r&  r  popr  r	   r  )rn   rW   rX  r  r9  r   reference_shapes          rw   test_mode_shape_gh_9955 TestMode.test_mode_shape_gh_9955
  s    ii##I.KKYK'..u5jj6qww-D!


%%chhnnoF


%%ciiooGrz   c                     S[         R                  S[         R                  /n[        R                  " U5      n[         R                  " UR                  5      (       a  UR
                  S:X  d   eg Nr1   r   )r   rm   ri   r  r  r  )rn   r9  r   s      rw   !test_nan_policy_propagate_gh_9815*TestMode.test_nan_policy_propagate_gh_9815
  sL     266"jjmxx!!cii1n44nrz   c                    [         R                  " S5      n[        R                  " USSS9nUR                  R                  UR
                  R                  s=:X  a  S:X  d   e   e[        R                  " USSS9nUR                  R                  UR
                  R                  s=:X  a  S:X  d   e   eSSS[         R                  /SS[         R                  S//n[        R                  " USSS9n[        UR                  SS/5        [        UR
                  S	S/5        [        R                  " USSS9n[        UR                  S/S//5        [        UR
                  S	/S//5        [         R                  " U5      n[        R                  " US SS9n[        R                  " UR                  5       SS
9n[        X#5        UR                  R                  UR                  R                  s=:X  a  S:X  d   e   e[        R                  " US SS9n[        R                  " UR                  5       SS
9n[        UR                  R                  5       UR                  R                  5       5        UR                  R                  S:X  d   e[        UR
                  R                  5       UR
                  R                  5       5        UR
                  R                  S:X  d   eS[         R                  [         R                  [         R                  S/[         R                  [         R                  [         R                  [         R                  S	/SS	[         R                  SS//n[        R                  " USSSS9n[        UR                  / SQ5        [        UR
                  / SQ5        [        R                  " USSSS9n[        UR                  S/S	/S//5        [        UR
                  S	/S/S	//5        [         R                  " U5      n[        R                  " US SSS9n[        R                  " UR                  5       SSS9n[        X#5        UR                  R                  UR                  R                  s=:X  a  S:X  d   e   e[        R                  " US SSS9n[        R                  " UR                  5       SSS9n[        UR                  R                  5       UR                  R                  5       5        UR                  R                  S:X  d   e[        UR
                  R                  5       UR
                  R                  5       5        UR
                  R                  S:X  d   eg )N)r   r1   r2   r   r   Fr  )r   r2   r   T)r   r   r2   r   r2   r1   r  r   rE  r4   r   )rW   r  r   )r   r1   r4   )r1   r   r1   )r  r   )r   rH  ri   r  r  r  rm   r	   r   r  r   )rn   r9  r   r  s       rw   test_keepdimsTestMode.test_keepdims
  s   HH\"jjU3xx~~=I=====jjT2xx~~@L@@@@@ ArvvArvvq 12jjU3388aV,399q!f-jjT2388qcA3Z0399sQCj1HHQKjj6jjU33$xx~~5255555jj5jjT2SXX^^%sxx~~'78xx~~'''SYY__&		(9:yy&((( +ffbffbffbffa0BFFAq!# jjUvF388Y/399i0jjTfE388qcA3_5399sQC!o6HHQKjj&IjjUvF3$xx~~5255555jjHjjTfESXX^^%sxx~~'78xx~~'''SYY__&		(9:yy&(((rz   r   r  r   c                    Sn[         R                  " U5      n[         R                  US'   [        R                  " USSUS9n[        UR                  / SQ5        [        UR                  / SQ5        [         R                  " S[         R                  4S	[         R                  S
4/5      n[         R                  " SUS9nSn[        R                  " [        US9   [        R                  " XaS9  S S S 5        g ! , (       d  f       g = f)N)r3   r2   r  r   F)r9  rW   r  r   r=  r1   r2   r2   r2   asdfqwerr  r\   rZ  z0Argument `a` is not....|An argument has dtype...r   r   )r   r  rm   ri   r  r	   r  rX  uint8r   rH  rP  r   	TypeError)rn   r   r  r  r   my_dtypetestr  s           rw   test_gh16955TestMode.test_gh16955
  s     wwu~VVT
jj4a%JO388\2399l3 88fbhh/&"**d1KLMxx(+D]]9G4JJt3 544s   C::
Dc                    [         R                  " [        [        S9   [        R
                  " / 5      nS S S 5        [        R                  S4n[        WU5        [         R                  " [        [        S9   [        R
                  " [        R                  /SS9nS S S 5        [        X5        / SQ[        R                  [        R                  [        R                  //n[         R                  " [        [        S9   [        R
                  " USSS9nS S S 5        S[        R                  /S	S/4n[        X5        [        R
                  " USS
S9nS[        R                  /S	S/4n[        X5        [        R                  " / / /5      n[         R                  " [        [        S9   [        R
                  " USS9nS S S 5        [        R                  [        R                  /SS/4n[        X5        g ! , (       d  f       GN= f! , (       d  f       GNv= f! , (       d  f       GN= f! , (       d  f       Nt= f)Nr   r   r   r   )r   r  r  r   r  r  r1   r  r2   rV   )rP  rQ  r   r   ri   r  r   rm   r   r   r   r   r   )rn   r   r  r9  zs        rw   test_gh9955TestMode.test_gh9955
  s    \\,4IJ**R.C KvvqkS#\\,4EF**bffX&9C GSrvvrvvrvv67\\,4EF**QQ6:C GBFF|aV$Sjj{;BFF|aV$SHHb"X\\,4IJ**QQ'C K!Q(S/ KJ
 GF
 GF KJs/   G:8%H H,H0:
H	
H
H-0
H>zignore::RuntimeWarningr-  r  r  c                    UR                   S:X  a=  [        R                  " [        [        S9   [
        R                  " US SS9nS S S 5        O[
        R                  " US SS9n[        R                  " US SS9nWS   R                  US   R                  s=:X  a  UR                  s=:X  a  S:X  d   e   eg ! , (       d  f       Nb= f)Nr   r   Tr  r   r  )
r  rP  rQ  r   r   ri   r  r   rl   r  )rn   r-  r   r  s       rw   test_gh17214TestMode.test_gh17214  s     66Q;08MNjj= ON **QTD9CggadT21v||s1v||EsyyEIEEEEE ONs   B88
Cc                    [         (       a  SOSn " S S5      n[        R                  " [        US9   [        R
                  " U" [        R                  " S5      5      5        S S S 5        [        R                  " [        US9   [        R
                  " [        R                  " S[        S95        S S S 5        g ! , (       d  f       N^= f! , (       d  f       g = f)Nz'...only boolean and numerical dtypes...z*Argument `a` is not recognized as numeric.c                   $    \ rS rSrS rSS jrSrg)8TestMode.test_raise_non_numeric_gh18254.<locals>.ArrLikei  c                     Xl         g r  _xru  s     rw   __init__ATestMode.test_raise_non_numeric_gh18254.<locals>.ArrLike.__init__  s    rz   Nc                 @    U R                   R                  [        5      $ r  )r8  r  object)rn   rX  copys      rw   	__array__BTestMode.test_raise_non_numeric_gh18254.<locals>.ArrLike.__array__  s    ww~~f--rz   r7  )NN)r   r   r   r   r9  r>  r   r   rz   rw   ArrLiker5    s    .rz   r@  r   r2   rZ  )	r.   rP  r   r'  ri   r  r   r   r<  )rn   r  r@  s      rw   test_raise_non_numeric_gh18254'TestMode.test_raise_non_numeric_gh18254  s    @O<D 		. 	. ]]9G4JJwryy|,- 5]]9G4JJryy&12 54 5444s   1B<.C<
C

Cr   N)r   r   r   r   r  rd  rF  r  rP  r  r  r   r   r  r
  r  rm   r  r   r  r  r   r*  r.  r  emptyr1  rA  r   r   rz   rw   r  r  5
  s   +,
!C( [[VRYYr1%562 721J [[V	
BFFAq!Q	
BFFAq	&  [[Z%7' 8' [[VRYYr1%5624** H 7H5:)x [[\K+@A4 B4": [[ 89[[S288I#68K"LMF N :F3rz   r  c                   F    \ rS rSr/ SQrSrS rS r\" SSS9S	 5       r	S
r
g)TestSEMi  r0  r   c                    UR                  U R                  5      S   n[        U5      (       a=  [        R                  " [
        [        S9   [        R                  " U5      nS S S 5        Og[        R                  R                  5        nUR                  [        5        UR                  [        5        [        R                  " U5      nS S S 5        UR                  W5      (       d   eg ! , (       d  f       N'= f! , (       d  f       N8= f)Nr   r   )rf   scalar_testcaser+   rP  rQ  r   r   ri   semr   r  r   r   UserWarningr   r  )rn   ro   rG  rq   r   s        rw   test_sem_scalarTestSEM.test_sem_scalar$  s     **T%9%9:2>B<<08MNIIo. ON --/3

;'

>*IIo. 0 xx{{{ ON 0/s   C,
AC=,
C:=
Dc                 0   UR                  U R                  5      n[        R                  " U5      n[	        X1R                  S5      5        [        U R                  5      n[	        [        R                  " USS9XDS-
  -  S-  -  [        R                  " USS95        UR                  S5      nUR                  US:H  UR                  UR                  5      U5      n[        [        R                  " U5      UR                  UR                  5      5        g )Ng㝎?r   ddofr1   r:   r   r8   )
rf   testcaseri   rH  r/   r  r   whererm   r0   )rn   ro   rO  rq   r  rp   s         rw   test_semTestSEM.test_sem6  s    ::dmm,IIh::l34		(3qA#wnD		(3	5 IIcNHHQ!VRZZ/3		!bjj&89rz   Tz(`nan_policy` only supports NumPy backendr   c                    [         R                  " S5      n[         R                  US'   [        [        R
                  " USS9S5        [        [        [        R
                  USS9  [        [        [        R
                  USS9  g )Nr   r8   r   r   gH=6?r   r   )r   r   rm   r   ri   rH  r   r   rn   ro   rp   s      rw   test_sem_nan_policyTestSEM.test_sem_nan_policyB  sX     IIcNvv!UYYqV46HIj%))Q7Cj%))Q8Drz   r   N)r   r   r   r   rO  rG  rJ  rQ  rH   rU  r   r   rz   rw   rE  rE    s:      HO$
: dGIEIErz   rE  zJAX can't do item assignmentc                      \ rS rSr\R
                  R                  S/ SQ/ SQ4/ SQ/ SQ4/5      S 5       rS rS r	\R
                  R                  S	S
S/5      S 5       r
\R
                  R                  S	S
S/5      S 5       rS rS rS rS r\" SSS9S 5       rS rS rS r\" SSS9S 5       rS rS rS r\" SSS9S 5       r\R
                  R                  S\R6                  " / 5      \R8                  " S5      /5      S  5       rS! r\S" 5       r \S# 5       r!S$ r"\R
                  R!                  S%S&S9S' 5       r#S(r$g))*TestZmapZscoreiL  zx, yr0  r  )r   r   rm  r1  r   c                     UR                  U5      UR                  U5      p![        X5      nXR                  U5      -
  UR                  USS9-  n[        R
                  " X5      n[        Xe5        g )Nr   r~   )rf   r)   rl   r   ri   zmapr/   )rn   rp   rq   ro   r   r  r-  s          rw   	test_zmapTestZmapZscore.test_zmapQ  s\     zz!}bjjm1!!'
Ngkk!k&BBJJq$rz   c                 .   [         R                  " / SQ/ SQ/ SQ/5      nSnSnSn[        R                  " X"SS9n[        R                  " X"S	S9nU* U* S
-  U* S
-  S/SXU* S
-  U/X5* S
-  XS* //n/ SQU* U* U* S// SQ/n	[	        Xh5        [	        Xy5        g Nr   r   r   r   )r   r   r   rm  )rm  r   rm  r   .!	?3Ey?;f?r   rV   r   r1   r   r>  r>  r   r   gLXz?)r   r>  r   r>  )r   r   ri   rZ  r/   
rn   ro   rp   t1t2t3z0r?  z0_expectedz1_expecteds
             rw   test_zmap_axisTestZmapZscore.test_zmap_axis_  s    HH***, - ZZ1%ZZ1%bSURCE3/RQ+CE2s+- .bS2#w/-/ 	((rz   c                    UR                  / SQ/ SQ/5      n[        R                  " X"SSS9nUR                  / SQ5      S-  nUR                  / SQ5      S-  n[        US	S S 24   U5        [        USS S 24   U5        g 
Nr_  )r   r   rm  r1  r   )rW   rN  )      ro  r:   r:   g3Ey?)      ro  r:   r;   g4?r   )rf   ri   rZ  r/   rn   ro   rp   r-  ri  rj  s         rw   test_zmap_ddofTestZmapZscore.test_zmap_ddofv  s{    JJ,,. / JJq!!,jj!78*Ejj!78D!Q$-!Q$-rz   rN  r   r1   c                 &   UR                  SSS[        R                  /5      nUR                  SSSSS[        R                  /5      n[        R                  " X4USS9n[        R                  " X4UR                  U5      )    US	9n[        XV5        g )
Nrc   rb   r1   r6   r^   r   rN  r   rM  )rf   r   rm   ri   rZ  r  r/   )rn   rN  ro   scorescomparer-  r  s          rw   test_zmap_nan_policy_omit(TestZmapZscore.test_zmap_nan_policy_omit  sy     RQ/0**b"aB78JJvTfEjj"((7*;);!<4Hrz   c           
      H   UR                  UR                  SS5      S5      nUR                  UR                  SSS5      S5      nUR                  US'   UR                  US'   UR                  US	'   [        R
                  " X4S
SUS9n[        R
                  " USS S 24   USS S 24   UR                  USS S 24   5      )    US9n[        R
                  " USS S 24   USS S 24   UR                  USS S 24   5      )    US9nUR                  Xg45      n[        XX5        g )N      r   r1   rb   ru  r5      )r   r3   r   rE  r   r   )r   rW   rN  r   rM  )	rk   r   r!  rm   ri   rZ  r  stackr/   )	rn   rN  ro   rw  rx  r-  r  r  r  s	            rw   #test_zmap_nan_policy_omit_with_axis2TestZmapZscore.test_zmap_nan_policy_omit_with_axis  s	   BIIdC0':**R[[Q3W=JJv6Mzz&A,1rxx17N6N(O#%zz&A,1rxx17N6N(O#%88TL)$rz   c                     UR                  / SQ5      nUR                  SSSSSUR                  /5      n[        R                  " [        SS9   [
        R                  " X#S	S
9  S S S 5        g ! , (       d  f       g = f)Nr  ru  rc   r1   r6   r^   zinput contains nanr   r   r   )rf   rm   rP  r   r   ri   rZ  )rn   ro   rw  rx  s       rw   test_zmap_nan_policy_raise)TestZmapZscore.test_zmap_nan_policy_raise  sY    I&**b"aB78]]:-ABJJv7; CBBs   A--
A;c                     [         R                  " UR                  / SQ5      5      n/ SQn[        X!R                  U5      5        g )Nr  )gOT\wg%ܿg%?gOT\w?)ri   zscorerf   r/   )rn   ro   rq   desireds       rw   test_zscoreTestZmapZscore.test_zscore  s3     LLL126::g./rz   c                 `   UR                  / SQ/ SQ/ SQ/5      nSnSnSn[        R                  " USS9n[        R                  " US	S9nU* U* S
-  U* S
-  S/SXU* S
-  U/X5* S
-  XS* //n/ SQU* U* U* S// SQ/n	[        XaR                  U5      5        [        XqR                  U	5      5        g r^  rf   ri   r  r/   rd  s
             rw   test_zscore_axisTestZmapZscore.test_zscore_axis  s    JJ,,,. / \\!!$\\!!$bSURCE3/RQ+CE2s+- .bS2#v.-/ 	JJ{34JJ{34rz   c                    UR                  / SQ/ SQ/5      n[        R                  " USSS9nUR                  / SQ5      S-  nUR                  / SQ5      S-  n[        US	S S 24   U5        [        USS S 24   U5        g rn  r  rq  s         rw   test_zscore_ddofTestZmapZscore.test_zscore_ddof  s{    JJ,,. / LL+jj!78*Ejj!78+F!Q$-!Q$-rz   r{   r|   rE   c                     UR                  SS[        R                  SS/5      n[        R                  " USS9n[        X1R                  UR                  UR                  5      5        g )Nr   r1   r3   r4   r  r   )rf   r   rm   ri   r  r0   r   r  rn   ro   rp   r-  s       rw   test_zscore_nan_propagate(TestZmapZscore.test_zscore_nan_propagate  sJ    JJ1bffa+,LL{377177BFF34rz   c                     UR                  SSUR                  SS/5      n[        R                  " USS9nUR                  SSUR                  S	S
/5      n[	        X45        g )Nr   r1   r3   r4   r   r   gIHb=gIHb=gIHb=?gIHb=?)rf   rm   ri   r  r/   )rn   ro   rp   r-  r  s        rw   test_zscore_nan_omit#TestZmapZscore.test_zscore_nan_omit  s_    JJ1bffa+,LLv.::22!vv11	! " 	$rz   c                 $   UR                  UR                  SSSSS/5      n[        U5      n[        R                  " USSS9nUR                  UR                  UR                  /5      [        R                  " USS  SS	9/5      n[        XE5        g )
Nr   r1  rO   r   r   r   r   rv  rM  )rf   rm   r)   ri   r  concatr/   )rn   ro   rp   r   r-  r  s         rw   test_zscore_nan_omit_with_ddof-TestZmapZscore.test_zscore_nan_omit_with_ddof  sy    JJS#sC89!!$LLv6>>2::rvvh#7aeRS9T"UV$rz   c                     UR                  SSUR                  SS/5      n[        R                  " [        SS9   [
        R                  " USS9  S S S 5        g ! , (       d  f       g = f)	Nr   r1   r3   r4   zThe input contains nan...r   r   r   )rf   rm   rP  r   r   ri   r  rT  s      rw   test_zscore_nan_raise$TestZmapZscore.test_zscore_nan_raise  sI    JJ1bffa+,]]:-HILLw/ JIIs   A
A'c                     UR                  S/S-  5      n[        R                  " [        SS9   [        R
                  " U5      nS S S 5        [        WUR                  UR                  UR                  5      5        g ! , (       d  f       N?= f)NgʡEr2   Precision loss occurred...r   )
rf   rP  rQ  r   ri   r  r0   r   r  rm   r  s       rw   test_zscore_constant_input_1d,TestZmapZscore.test_zscore_constant_input_1d  s_    JJx!|$\\.0LMQA N277177BFF34 NMs   A??
Bc                    UR                  / SQ/ SQ/5      n[        R                  " [        SS9   [        R
                  " USS9nS S S 5        [        WUR                  UR                  SSS/UR                  SSS//5      5        [        R                  " [        SS9   [        R
                  " US	S9nS S S 5        [        WUR                  UR                  UR                  UR                  UR                  UR                  /5      [        R
                  " US	S S 24   5      /5      5        [        R
                  " US S9n[        XQR                  [        R
                  " UR                  US
5      5      UR                  5      5        UR                  S5      n[        R                  " [        SS9   [        R
                  " US S9nS S S 5        [        XQR                  UR                  UR                  UR                  5      5      5        g ! , (       d  f       GN= f! , (       d  f       GNy= f! , (       d  f       Nq= f)Nr   r   r   r   r   r  r        *@r  r   r   rV   r>  r   r   rb   )r2   r5   )rf   rP  rQ  r   ri   r  r/   rm   r0   r  rk   r  r  r   )rn   ro   rp   rh  r?  r-  rq   s          rw   test_zscore_constant_input_2d,TestZmapZscore.test_zscore_constant_input_2d  s   JJ002 3\\.0LMaa(B NBJJtT(B)+c3(?(A B 	C \\.0LMaa(B NBHHbjj"&&"&&"&&"&&1Q&R&+ll1QT7&;&= > 	? LL&::ell2::a3G&H!''RSGGFO\\.0LMQT*A N77177BJJrvv,>?@! NM
 NM NMs#   H!H):H;
H&)
H8;
I	c                 P   UR                  / SQSSSUR                  /SSUR                  S//5      nSnSn[        R                  " [        SS9   [
        R                  " US	S
S9nS S S 5        [        WUR                  UR                  U* SUR                  /UR                  S
SUR                  /UR                  X1R                  UR                  //5      5        [        R                  " [        SS9   [
        R                  " US	SS9nS S S 5        [        WUR                  UR                  UR                  UR                  UR                  /U* S
X1R                  /U* S-  XAR                  U* S-  //5      5        g ! , (       d  f       GN%= f! , (       d  f       N= f)Nr  r   r  r  r`  rb  r  r   r   r   r   rW   r>  r   r   r1   )rf   rm   rP  rQ  r   ri   r  r/   )rn   ro   rp   rp  s2rh  r?  s          rw   -test_zscore_constant_input_2d_nan_policy_omit<TestZmapZscore.test_zscore_constant_input_2d_nan_policy_omit  sf   JJ0tT2662tRVVT24 5 \\.0LMaF;B NBJJ!T266(B)+C(@)+FFBFF(C(E F 	G \\.0LMaF;B NBJJ(H*+Q66(:*,QFFRCE(B(D E 	F NM NMs   F8F
F
F%c           	         UR                  [        R                  [        R                  [        R                  [        R                  // SQ/5      n[        R                  " USSS9n[        X1R                  [        R                  [        R                  [        R                  [        R                  // SQ/5      5        g )N)r   r   r  r  r   r   r  rc  )rf   r   rm   ri   r  r/   r  s       rw   test_zscore_2d_all_nan_row)TestZmapZscore.test_zscore_2d_all_nan_row  s}    JJ802 3LLvA6::'G'='? @ 	Arz   c                 ~    UR                  SUR                  5      n[        R                  " USS S9n[	        X25        g )NrF  r   r  )r   rm   ri   r  r0   )rn   ro   rq   r-  s       rw   test_zscore_2d_all_nan%TestZmapZscore.test_zscore_2d_all_nan"  s2     GGFBFF#LLvD9rz   rp   )r2   r   r4   c                 h    UR                  U5      n[        R                  " U5      n[        X15        g r  )rf   ri   r  r0   )rn   rp   ro   r-  s       rw   test_zscore_empty_input&TestZmapZscore.test_zscore_empty_input)  s$    JJqMLLOrz   c           	         [         R                  " / SQ5      n[        R                  " UR                  U5      5      n[         R                  " U[        R
                  " U5      -  5      [         R                  " [        R                  " USS95      -  n[        X1R                  XAR                  S5      R                  S95        g )Nr  r   rM  r   rZ  )	r   rf   ri   gzscoreloggmeangstdr/   rX  )rn   ro   rp   r-  r  s        rw   test_gzscore_normal_array(TestZmapZscore.test_gzscore_normal_array/  s{    JJ|$MM"**Q-(&&U[[^+,rvvejj6K/LL::gZZ^5I5I:JKrz   c                    [         R                  " / SQ5      n/ SQn[         R                  R                  X#S9n[        R
                  " U5      nSS[         R                  SS/n[         R                  R                  XcS9n[        UR                  5       UR                  5       5        [        UR                  UR                  5        [        U[         R                  R                  5      (       d   eg )N)r   r1   rb   r2   r3   )r   r   r   r   r   maskg0jg`ȿg/A?g(/?)r   r   rc  masked_arrayri   r  r  r   
compressedr  r#  MaskedArray)rn   ro   rp   r  mxr-  r  s          rw   test_gzscore_masked_array(TestZmapZscore.test_gzscore_masked_array5  s    HH%&UU-MM"#_bffn"$%%$$W$8(:(:(<=-!RUU..////rz   c                    [         R                  R                  S5      nUR                  S5      n[         R                  " U5      n[         R
                  R                  X45      nSUR                  S'   [        R                  " USS  5      n[         R                  " [         R                  " U5      5      (       a   e[        R                  " U5      n[        USS  U5        [        R                  " US S9n[        USS  U5        US   USS & [        R                  " [        SS9   [        R                  " U5      nS S S 5        [!        USS  [         R"                  5        [        R                  " [        SS9   [        R                  " US S9nS S S 5        [!        USS  [         R"                  5        g ! , (       d  f       N= f! , (       d  f       N== f)	Ni_ r\   Tr   r   rV   r  r   )r   r  r  standard_normal
zeros_likerc  r  r  ri   r  r  r  r   rP  rQ  r   r   rm   )rn   ro   r  rp   r  rq   r  r   s           rw   $test_zscore_masked_element_0_gh190393TestZmapZscore.test_zscore_masked_element_0_gh19039B  sW    ii##G,#}}QEEq'q	ll1QR5!66"((3-((((ll1oAB%ll14(AB%!!"\\.0LM,,q/C NSWbff%\\.0LM,,qt,C NSWbff% NM NMs   )F:>G:
G
Gc                 X   UR                  S5      nUR                  S5      nUR                  UR                  * UR                  UR                  /5      n[
        R                  " [        SS9   [        R                  " X#5      nS S S 5        [        WU5        g ! , (       d  f       N= f)Nr2   r  r   )r   r  rf   r  rm   rP  rQ  r   ri   rZ  r0   )rn   ro   rw  rx  r  r   s         rw   test_degenerate_input$TestZmapZscore.test_degenerate_inputZ  sv    1''!*jj266'26626623\\.0LM**V-C NS! NMs   /B
B)rG   needs array-api#850c                     [         R                  " UR                  / SQ5      UR                  / SQ5      5      nUR                  / SQ5      n[        X#5        g )Nr  )r                 ?rb   r  )y      ?        y       @        y      @        y      @        )ri   rZ  rf   r/   )rn   ro   r   r  s       rw   test_complex_gh22404#TestZmapZscore.test_complex_gh22404b  s<    jjL12::>N3OPjj9:!rz   r   N)%r   r   r   r   rP  r  r  r[  rk  rr  ry  r  r  r  r  r  rH   r  r  r  r  r  r  r  r  r  r   r   rH  r  r  r(   r  r  r  r  r   r   rz   rw   rX  rX  L  s   
 [[
,	-
,	-	/
%
%).
. [[VaV,  -  [[VaV,% -%<05.
. f%565 75
%%0
 f%565 75A*F&A f%56 7 [[S288B<)1D"EF G
L 
0 
0 & &." [[!!"4=R!S" T"rz   rX  c            
          \ rS rSrS rS rS rS rS r\	R                  R                  S/ SQ5      S	 5       r\	R                  R                  S
S\R                  " \R                  SS/5      4S\R                  " \R                  \R                  S/5      4/5      S 5       r\	R                  R                  SS/ SQ4S/5      S 5       rS rSrg)TestMedianAbsDeviationii  c                     [         R                  " SSSSSSSSSSSS	S
S
S
SSSSSSSS[         R                  /5      U l        [         R                  " / SQ5      U l        g )N皙@rs  r<   皙@r  333333@=
ףp=@r  (\
@rt  r=   r  皙@)\(@Q@)r  r  rs  rs  r<   r  r  r  r  r  r  r  rt  rt  rt  r=   r  r  r  r  r  r  r  g33333<@)r   r   rm   dat_nandatrh  s    rw   setup_class"TestMedianAbsDeviation.setup_classj  sg    xxtS#sCc!%tT4c3!$c3S$bff!N O 88 ? @rz   c                     [        [        R                  " U R                  S S9S5        U R                  R	                  SS5      n[        R                  " USS9n[
        R                  " / SQ5      n[        X#5        g )NrV   gQ?r5   r3   r   )gףp=
?r:   ?rj  )r   ri   median_abs_deviationr  rk   r   rf   r   )rn   r  madmad_expecteds       rw   test_median_abs_deviation0TestMedianAbsDeviation.test_median_abs_deviationr  s_    E66txxdK!	#hhq!$((15zz"9:!#4rz   c                 Z    [         R                  " U R                  SS9n[        US5        g )Nr   r   g(\?)ri   r  r  r   )rn   r  s     rw   test_mad_nan_omit(TestMedianAbsDeviation.test_mad_nan_omitz  s"    ((&IC&rz   c                     [         R                  " SSSS[         R                  // SQ/5      n[        R                  " USS9n[        U[         R                  " [         R                  S/5      5        g )Nr   rm  r1  r   )r   r   rO   r   r   r   rV   r   r   rm   ri   r  r   )rn   rp   r  s      rw   test_axis_and_nan(TestMedianAbsDeviation.test_axis_and_nan~  sV    HHsCc2662/1 2((3S"((BFFC=12rz   c           	          [         R                  " SSSSS[         R                  [         R                  /5      n[        R
                  " USS9n[        US5        g )	Nr   r2   r3   r5   r  r   r   r1  )r   r   rm   r  ri   r  r   )rn   r-  r  s      rw   test_nan_policy_omit_with_inf4TestMedianAbsDeviation.test_nan_policy_omit_with_inf  sC    HHaAq"bffbff56((v>S#rz   rW   )r   r   r1   Nc           	          [         R                  " S5      n[        R                  " X!S9n[	        U[         R
                  " UR                  US9[         R                  S95        g )N)r2   r   r3   rV   
fill_value)r   rH  ri   r  r   	full_likerM  rm   )rn   rW   rp   r  s       rw   test_size_zero_with_axis/TestMedianAbsDeviation.test_size_zero_with_axis  sD    HHY((6S",,quu$u'7BFFKLrz   znan_policy, expectedr   r;   r  c           	      r   [         R                  " [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  /SSSS[         R                  [         R                  // SQ/5      n[        R                  " X1SS9n[        XB5        g )Nr   r4   r2   r5   )r4   r5   r6   r8   r8   r\   r  r  )rn   r   r  rp   r  s        rw   test_nan_policy_with_axis0TestMedianAbsDeviation.test_nan_policy_with_axis  su     HHrvvrvvrvvrvvrvvrvvF!Q2662662)+ , ((JS#rz   zaxis, expectedr   )r<   rm  r  )Nr>   c                     [         R                  " SSSS[         R                  // SQ/ SQ/5      n[        R                  " U[         R
                  SUS9n[        XBS	S	S
9  g )Nr   r1   r3   r8   )r   r   r   r   r^   )r  r  r  r  r   )centerr   rW   r2  r  )r   r   rm   ri   r  rl   r   )rn   rW   r  rp   r  s        rw   test_center_mean_with_nan0TestMedianAbsDeviation.test_center_mean_with_nan  sY     HHq!Q266*&-/ 0 ((277v.24E>rz   c                     [         R                  " [        SS9   [        R                  " / SQSS9  S S S 5        g ! , (       d  f       g = f)Ncallabler   )r   r1   r2   r4   r  r   )rP  r   r'  ri   r  rh  s    rw   test_center_not_callable/TestMedianAbsDeviation.test_center_not_callable  s,    ]]9J7&&|B? 877s	   ;
A	)r  r  N)r   r   r   r   r  r  r  r  r  rP  r  r  r  r   r   rm   r  r  r  r   r   rz   rw   r  r  i  s    @5'3
 [[V_5M 6M
 [[3%rxxc0B'CD*BHHbffbffc5J,KLNO$O$ [[- "23[AC?C?@rz   r  c                 p    [        [        U 5      US5        U  H  n[        UR                  UL 5        M     g)z
Checks that all of the warnings from a list returned by
`warnings.catch_all(record=True)` are of the required type and that the list
contains expected number of warnings.
znumber of warningsN)r   r  r   category)	warn_listexpected_typeexpected_lenwarn_s       rw   _check_warningsr    s0     Y/CD-/0 rz   c                       \ rS rSrS rS r\R                  R                  S/ \	R                  " S5      /5      S 5       rS rS rS	 rS
 rS rS rS rS rS rSrg)TestIQRi  c                     [         R                  " S5      S-  n[         R                  R                  U5        [	        [
        R                  " U5      S5        g )Nr7   r:   r  )r   r   r  rn  r   ri   iqrru  s     rw   rF  TestIQR.test_basic  s8    IIaL3
		!UYYq\4(rz   c           	         [         R                  " S5      n[        R                  " U5        [        R                  " US 5        [        R                  " US5        [        R                  " US5        [        R                  " US S5        [        R                  " US SS5        [        R                  " US SSS	5        [        R                  " US S
SSS5        [        R                  " US SSSSS5        g )Nrm  r   rD  )r\   Z   )r  r  r   )r  r  r;   r  )r   r   r  r   lineargٿr   r  T)r   r  ri   r  )rn   rZ  s     rw   test_apiTestIQR.test_api  s    GGFO		!		!T		!Q		!V		!T8$		!T8S)		!T8S+6		!T8XwA		!T8T67DArz   rp   r   c                     [         R                  " [        [        S9   [	        [
        R                  " U5      [        R                  5        S S S 5        g ! , (       d  f       g = fr  )	rP  rQ  r   r   r   ri   r  r   rm   ru  s     rw   r  TestIQR.test_empty  s5    \\,4IJ1rvv. KJJs   /A
A$c                 6   [         R                  " S5      n[        [        R                  " U5      S5        [        [        R                  " USS9[         R                  " S5      5        [        [        R                  " USS9[         R                  " S5      5        [        [        R                  " USS	9S5        [        [        R                  " US
S	9S5        [        [        R                  " USS	9S5        [        [        R                  " USS	9S5        [        [        R                  " USS	9S5        [         R                  " S5      [         R                  " S5      -  n[        [        R                  " USS9[         R                  " S5      5        [        [        R                  " USS9[         R                  " S5      5        [        [        R                  " USS9[         R                  " SS5      5        [        [        R                  " USS9[         R                  " S5      5        [        [        R                  " USS9[         R                  " SS5      5        [        [        R                  " USS9[         R                  " SS5      5        g )N)r6   r3   r   r   rV   r3   r   r6   r  interpolationmidpointnearestr  r  r3   r4   r5   r5   )r4   r5   )r3   r5   r1   )r3   r4   r<   rD  r   r1   r4   r1  r   r1   )	r   r  r   ri   r  r	   rH  r   r   rp  s      rw   test_constantTestIQR.test_constant  s   GGFOUYYq\3'599QQ/!=599QQ/!=UYYq93?UYYq
;SAUYYq	:C@UYYq8#>UYYq93? GGI1-599QQ/&1AB599QQ/&1AB599QQ/1EF599QV4bhhqkB599QV4bgganE599QV4bgganErz   c                     [         R                  " S5      S-   n[        [        R                  " US   5      S5        [        [        R                  " U5      S5        [        [        R                  " USS9S/5        g )Nr   r   r   r   Tr  )r   r   r   ri   r  r	   ru  s     rw   test_scalarlikeTestIQR.test_scalarlike  sS    IIaL3UYYqt_c*UYYq\3'599Q6>rz   c                    [         R                  " S5      R                  S5      n[        [        R
                  " U5      S5        [        [        R
                  " USS9[         R                  " SS5      5        [        [        R
                  " USS9[         R                  " S	S
5      5        [        [        R
                  " USS9S5        [        [        R
                  " USS9S5        g )Nr  r  r   r   rV   r4   rO   r   r2   rm  rD  r  )r   r   rk   r   ri   r  r	   r   ru  s     rw   test_2DTestIQR.test_2D  s    IIbM!!&)UYYq\3'599QQ/B@599QQ/B@599QV4c:599QV4c:rz   c                    [         R                  R                  SS9n[         R                  " U/S-  5      n[        R
                  " U5      n[        [        R
                  " USS9U5        [         R                  " USS5      n[        [        R
                  " USS9U5        UR                  SS	5      n[        [        R
                  " US
S9U5        UR                  SS	5      n[        [        R
                  " USS9[        R
                  " US S95        [        [        R
                  " USS9[        R
                  " USS95        [         R                  " S5      n[         R                  R                  U5        UR                  S5      n[        [        R
                  " USS9S   [        R
                  " US S 2S S 2S S 2S4   R                  5       5      5        [        [        R
                  " USS9S	   [        R
                  " US S 2S S 2S	S S 24   R                  5       5      5        [        [        R
                  " USS9S   [        R
                  " US S 2S S 2SS S 24   R                  5       5      5        [        [        R
                  " USS9S   [        R
                  " USS S 2S S 2S S 24   R                  5       5      5        [        [        R
                  " USS9S   [        R
                  " USS	S S 2S S 24   R                  5       5      5        [        [        R
                  " USS9S   [        R
                  " USS S 2S S 2S	4   R                  5       5      5        [        [        R
                  " USS9S   [        R
                  " USS S 2SS S 24   R                  5       5      5        [        [        [        R
                  USS9  [        [        [        R
                  USS9  g )N)G   r  r  r\   rD  rV   rb   r   r  r   r!  r  r   i  r2   r4   r6   r]   r   r   r2   )r2   r   r  r1   )r2   r   r1   r2   r1   )r   rQ  )r   r2   r1   r1   r3   r  )r   r  r  dstackri   r  r   moveaxisswapaxesr   rn  rk   r  r   r&   r   )rn   orp   qrZ  s        rw   r  TestIQR.test_axis  s   II(+IIqcBhIIaLUYYqv.2KK2q!UYYqv.2JJq!UYYqv.2JJq!UYYqy1YYqt,	.UYYqt,YYqq)	+ IIn% 			!IIm$UYYqy1!4YYq1Q{0023	5UYYqy1!4YYq1a{0023	5UYYqz215YYq1a{0023	5UYYqy1!4YYq1Qqz//12	4UYYqv.t4YYqAa{0023	5UYYqw/5YYqAq!}2245	7UYYqv.t4YYqAq|1134	6 	iAA6j%))QV<rz   c                    [         R                  " S5      n[        [        R                  " U5      S5        [        [        R                  " USS9S5        [        [        R                  " USS9S5        [        [        R                  " USS9S5        [        [        [        R                  US	S9  [        [        [        R                  U[         R                  S
4S9  [        [        [        R                  USS9  g )Nr4   r1   )r  g     U@r  r<   )g      )@r  )r\   r   g?)r   r  r  )r   r   <   )
r   r   r   ri   r  r   r   r   rm   r'  ru  s     rw   test_rngTestIQR.test_rng  s    IIaLUYYq\1%UYYqj137UYYqj137EIIaX6<j%))QH=j%))QRVVRLAiA;?rz   c                 ~   [         R                  " S5      n[         R                  " S5      n[        [        R                  " U5      S5        [        [        R                  " U5      S5        [        [        R                  " USS9S5        [        [        R                  " USS9S5        [        [        R                  " USS9S5        [        [        R                  " USSS	9S
5        [        [        R                  " USS9S5        [        [        R                  " USS9S5        [        [        R                  " USSS	9S5        [        [        R                  " USS9S5        [        [        R                  " USS9S5        [        [        R                  " USS9S5        [        [        R                  " USS9S5        [        [        R                  " USSS	9S5        [        [        R                  " USS9S5        S H  n[        R                  " X#S9  M     [        [        [        R                  USS9  g )Nr4   r3   r1   r;   r  r  r  )r  P   )r  r  r2   r  r  r   r  r<   )inverted_cdfaveraged_inverted_cdfclosest_observationinterpolated_inverted_cdfhazenweibullmedian_unbiasednormal_unbiasedr   )r   r   r   ri   r  r   r   )rn   rp   rq   r  s       rw   test_interpolationTestIQR.test_interpolation#  s   IIaLIIaLUYYq\1%UYYq\3'UYYq91=UYYq93?UYYq91=UYYqhhGKUYYq91=UYYq8!<UYYqhgFJUYYq8!<UYYq	:A>UYYq	:A>UYYq
;Q?UYYqhjI3OUYYq
;Q?*F IIa.	* 	j%))QhGrz   c                    [         R                  " S5      n[        [        R                  " US SS9R
                  S5        [        [        R                  " USSS9R
                  S5        [        [        R                  " USSS9R
                  S5        [        [        R                  " US	SS9R
                  S
5        [        [        R                  " USSS9R
                  S5        [        [        R                  " USSS9R
                  S5        [        [        R                  " USSS9R
                  S5        [        [        R                  " US SS9R
                  S5        [        [        R                  " USSS9R
                  S5        [        [        R                  " USSS9R
                  S5        [        [        R                  " US	SS9R
                  S5        [        [        R                  " USSS9R
                  S5        [        [        R                  " USSS9R
                  S5        [        [        R                  " USSS9R
                  S5        g )Nr.  Fr  r   r1   )r2   r4   r]   rD  )r6   r]   )r   r2   )r4   r6   )r   r  r   r   r1   r2   r  r/  r   Tr=  )r2   r4   r   r]   )r   r   r6   r]   )r   r4   r6   r   )r2   r   r6   r]   )r   r   r6   r   )r   r  r   ri   r  r  ru  s     rw   r   TestIQR.test_keepdimsE  s   GGM"UYYqte<BBBGUYYqq59??LUYYqv>DDgNUYYqv>DDfMUYYqte<BBJOUYYq,?EErJUYYqy5AGGNUYYqtd;AA<PUYYqq48>>NUYYqv=CC]SUYYqv=CC\RUYYqtd;AA=QUYYq,>DDlSUYYqy4@FFUrz   c           	      B   [         R                  " S5      R                  S5      n[        [        R
                  " USS9S5        [        [        R
                  " USS9S5        [        [        R
                  " USS9S5        [         R                  US'   [        R                  " S	S
9   [        R                  " S5        [        [        R
                  " USS9[         R                  5        [        [        R
                  " USSS9SS[         R                  SS/5        [        [        R
                  " USSS9S[         R                  S/5        S S S 5        [        R                  " S	S
9   [        R                  " S5        [        [        R
                  " USS9S5        [        [        R
                  " USSS9[         R                  " SS5      5        [        [        R
                  " USSS9/ SQ5        S S S 5        [        [        [        R
                  USS9  [        [        [        R
                  USSS9  [        [        [        R
                  USSS9  [        [        [        R
                  USS9  g ! , (       d  f       GN3= f! , (       d  f       N= f)N      .@r  r  r   r6   r   r   r"  Tr   alwaysr   r  r4   r   r1   rA   )r1   r<   r1   barfood)r   r   rk   r   ri   r  rm   warningscatch_warningssimplefilterr   r   r   ru  s     rw   test_nanpolicyTestIQR.test_nanpolicyX  s   IIdO##F+ 	UYYq[91=UYYqV4a8UYYqW5q9 &&$$$D1!!(+1=!11EQ1-/11ERVVQ) 2 $$D1!!(+18#>11@"''!Q-P11@+N	 2 	j%))Q7Cj%))QQ7Kj%))QQ7K 	j%))Q9E) 21 21s   *B(I>.BJ>
J
Jc           
          [         R                  " S5      R                  S5      n[        [        R
                  " USS9S5        [        [        R
                  " USS9S5        [        [        R
                  " USS9S	5        [         R                  US
'   [        R                  " SS9   [        R                  " S5        [        [        R
                  " USSS9[         R                  5        [        [        R
                  " USSS9[         R                  5        [        [        R
                  " USSS9[         R                  5        [        [        R
                  " USSSS9S[         R                  S/5        [        [        R
                  " USSSS9[         R                  " S[         R                  S/5      S-  5        [        [        R
                  " USSSS9S[         R                  S/5        S S S 5        [        [        R
                  " USSS9S5        [        [        R
                  " USSS9S5        [        [        R
                  " USSS9S5        [        [        [        R
                  USS9  g ! , (       d  f       N= f)NrL  r  r   r  r6   r  g=V^w@rm  r=   r"  TrM  rN  r  )r  r   r   )rW   r  r   r1   gF7k?r   rA   g	I1=@g      @r   )r   r   rk   r   ri   r  r   rm   rP  rQ  rR  r   r   r   ru  s     rw   
test_scaleTestIQR.test_scalex  s   IIdO##F+ 	UYYq,a0EIIax8-HUYYq,c2 &&$$$D1!!(+1CKH"&&Q1HMrvvV1CKH"&&Q11C.9;=>NL		!!85@!B "!RVVQ 89 DF 11CKPRVVQ) 2" 	UYYq?EEIIaxFK+	-UYYq?F 	j%))Qh?/ 21s   *EI??
Jr   N)r   r   r   r   rF  r  rP  r  r  r   r   r  r#  r&  r)  r  r:  rF  r   rS  rW  r   r   rz   rw   r  r    su    )

B [[S2ryy|"45/ 6/F,?;'=R	@ HDV&F@!@rz   r  c            	       $   \ rS rSrSr/ SQrSr\R                  R                  S5        \R                  R                  S5      rSSS.S	 jr\\R                  R!                  S
SS/5      \R                  R!                  S\" SS5      5      S 5       5       5       r\\R                  R!                  S
SS/5      \R                  R!                  SS5      S 5       5       5       r\S 5       rS r\" SSS9\R                  R/                  S5      \\R                  R!                  S/ SQ5      \R                  R!                  SSS/5      S 5       5       5       5       5       r\" SS S9\R                  R/                  S5      \S! 5       5       5       r\S" 5       r\S# 5       rS$ r\\R                  R!                  S%/ SQ5      \R                  R!                  S&/ S'Q5      \R                  R!                  S(SS)/5      S* 5       5       5       5       rS+rg),TestMomentsi  aC  
Comparison numbers are found using R v.1.5.1
note that length(testcase) = 4
testmathworks comes from documentation for the
Statistics Toolbox for Matlab and can be found at both
https://www.mathworks.com/help/stats/kurtosis.html
https://www.mathworks.com/help/stats/skewness.html
Note that both test cases came from here.
r0  r     rm  N)r  rX  c                    [         R                  " U5      nUb  [         R                  " X#5      n[        X5        Uc  UR                  nUR                  U:X  d   eg r  )r   rf   broadcast_tor	   rX  )rn   r  expectr  rX  s        rw   _assert_equalTestMoments._assert_equal  sL    F#__V3F6*=LLE||u$$$rz   r  r\   )r\   r1   zm, crI  )Nr   r   c                 0   [         R                  R                  S5      nUR                  UR                  US95      n[        R
                  " XbUS9nUc  UR                  USS9OUnUR                  Xc-
  U-  SS9UR                  S   -  n[        XxSS9  g )Nl   rHZ r  r  r   rV   缉ؗҜ<r3  )
r   r  r  rf   ri   momentrl   rM  r  r/   )	rn   r  r  rY  ro   r  rp   r   r  s	            rw    test_moment_center_scalar_moment,TestMoments.test_moment_center_scalar_moment  s     ii##$78JJszztz,-ll1*"#)BGGAAGffaeaZaf(3u-rz   rY  c                 n   [         R                  R                  S5      nUR                  UR                  US95      n/ SQn[        R
                  " XVUS9n[        U5      nUR                  U V	s/ s H'  n	[        R
                  " XYUS9UR                  S4   PM)     sn	5      n
[        Xz5        g s  sn	f )Nl   %~.}~= r  rI  r  .)
r   r  r  rf   ri   rc  r)   r  newaxisr0   )rn   r  rY  ro   r  rp   r  r   r   r  r  s              rw   test_moment_center_array_moment+TestMoments.test_moment_center_array_moment  s     ii##$78JJszztz,-ll1*!!$nn'(*'(! $ll1:7??C;OP'(* +!*s   1.B2c                   ^ TR                  U R                  5      n[        R                  " TR                  U R                  5      5      n[        UTR                  S5      5        [        R                  " US5      n[        UTR                  S5      5        [        R                  " US5      n[        UTR                  S5      5        [        R                  " US5      n[        UTR                  S5      5        [        R                  " US5      n[        UTR                  S5      5        [        R                  " US5      n[        UTR                  S	5      5        [        R                  " U/ S
Q5      n[        UTR                  / SQ5      5        [        R                  " US5      n[        UTR                  S5      5        Sn[        R                  " [        US9   [        R                  " US5        S S S 5        [        R                  " U/ SQ5      n[        UTR                  / SQ5      5        U4S jn[        T5      (       a*  [        R                  " [        SS9   U" 5         S S S 5        g [        R                  R                  5        nUR                  [         S5        UR                  [         S5        U" 5         S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f! , (       d  f       g = f)Nr   r   r   r   r1         ?r2   r3        @r  )r   rk  r   rl  z)All elements of `order` must be integral.r   333333?)r   r1   r2   r   c                    > [         R                  " TR                  / 5      5      n [        U TR                  TR                  5      5        [         R                  " TR                  / TR
                  S95      n [        U TR                  TR                  TR
                  S95        [         R                  " TR                  S5      SS9n [        U TR                  S5      5        [         R                  " TR                  / /5      SS9n [        U TR                  TR                  /5      5        [         R                  " TR                  / /5      SS/SS9n [        U TR                  S5      5        g )	NrZ  r  r   rV   r-  r   orderrW   )r1   r   )ri   rc  rf   r0   rm   r   rH  rC  )rq   ro   s    rw   
test_cases+TestMoments.test_moment.<locals>.test_cases  s   RZZ^,AArzz"&&12RZZ"**Z=>AArzz"&&

zCDRXXf-A6AArxx~.RZZ-A6AArzz266(34RZZ-aV!DAArxx/0rz   zSee documentation for...zMean of empty slice.zinvalid value)rf   rO  ri   rc  rG  r/   rP  r   r   r+   rQ  r   r   r  r   r   r   )rn   ro   rO  rq   r  rq  r   s    `     rw   test_momentTestMoments.test_moment  s    ::dmm,LLD$8$89:2::c?+LL1%2::c?+LL1%2::c?+LL1%2::d+,LL1%2::c?+LL1%2::f-. LL<02::&:;< LL3'2::c?+=]]:W5LL3' 6LL#342::&:;<
	1 B<<08RS TS --/3

>+AB

>?; 0/- 65& TS 0/s$   $K)K&4K7
K#&
K47
Lc                 j   [         R                  " S5      n[         R                  US'   [        [        R
                  " US5      [         R                  5        [        [        R
                  " USS9S5        [        [        [        R
                  USS9  [        [        [        R
                  USS9  g )	Nr   r8   r1   r   r   r   r   r   )	r   r   rm   r   ri   rc  r   r   r   ru  s     rw   ry  TestMoments.test_nan_policy  sn    IIcNvv!U\\!Q'0ELLv>Dj%,,gFj%,,hGrz   r{   r|   rE   rH   rX  )r   r   
complex128zexpect, orderrD  r  c           	         US:X  a%  [        U5      (       a  [        R                  " 5         [        XA5      nUR	                  [
        R                  R                  S5      US9n[        R                  " XSS9n[        XdR	                  X!S95        [        R                  " UR                  US5      SUS9n[        XdR                  SX!S95        [        R                  " UR                  US	5      S
US9n[        XdR                  SX!S95        [        R                  " UR                  US	5      S US9n[        XdR                  SX!S95        g )Nrw  r4   rZ  rp  )r5   r4   r   )rW   rp  )r4   r  r1   )r   r1   r3   r4   r   )r,   rP  skipr[  rf   r   r  r|  ri   rc  r0   r]  r   )rn   rX  r^  rp  ro   rp   rq   s          rw   test_constant_moments!TestMoments.test_constant_moments
  s    ,8B<<KKM"JJryy~~a(J6LL(::f::;LLF3!5I7747=>LLO<1$&77<7EFLLO<4$&772v7;<rz   rC   r/  c                     UR                  UR                  S5      S5      n[        R                  US'   [        R
                  " USSS9n[        X1R                  S[        R                  /5      SS	9  g )
Nr   r}  r  r1   r   rV   rk  r2  r3  )rk   r   r   rm   ri   rc  r/   rf   )rn   ro   r9  mms       rw   test_moment_propagate_nan%TestMoments.test_moment_propagate_nan"  sV     JJryy}g.&&$\\!QQ'JJbff~6UCrz   c                     [         R                  " [        SS9   [        R                  " UR                  / SQ5      / S9  S S S 5        g ! , (       d  f       g = f)Nz1`order` must be a scalar or a non-empty 1D array.r   r  ry  )rP  r   r   ri   rc  rf   rn   ro   s     rw   test_moment_empty_order#TestMoments.test_moment_empty_order.  sC     ]]: .E FLLL1<F F Fs   'A


Ac                     UR                  S5      n[        R                  " USS9n[        R                  " USS9n[        X45        g )Nr\   r2   )rc  ry  )r   ri   rc  r0   )rn   ro   rp   r   r  s        rw   test_rename_moment_order$TestMoments.test_rename_moment_order5  s9     IIbMll1Q'll1A&!rz   c                     U R                   [        R                  " U R                   5      -
  n[        [        R                  " US5      R                  5       [
        R                  " U R                   S5      5        g )Nrm  )testcase_moment_accuracyr   rl   r   r   ri   rc  )rn   
tc_no_means     rw   test_moment_accuracy TestMoments.test_moment_accuracy>  sY     33 = =>?
R0557T%B%BBG	Irz   rp  rW   rB  r   r   c           	          [         R                  R                  S5      nUR                  SS9n[        R                  " UR                  U5      X#US9nUR                  [        XbX4S95      n[        Xx5        g )Nl   hU~)r4   r5   r6   r  )rW   r   )rl   )r   r  r  ri   rc  rf   r!   r/   )	rn   ro   rp  rW   r   r  rp   r   r  s	            rw   test_moment_array_api!TestMoments.test_moment_array_apiF  s_    
 ii##N3JJIJ&ll2::a=%6Jjj4=>!rz   r   )r   r   r   r   r   rO  rG  r   r  rn  r|  r  r_  r'   rP  r  r  r   rd  rh  rs  ry  rH   usefixturesr{  r  r  r  r  r  r   r   rz   rw   rZ  rZ    s@     HOIINN4!yy~~b159 % [[Vb']3[[VW\<%HI. J 4 . [[Vb']3[[S,/" 0 4 " 3 3jH f%56[[/0[[W&JK[[_vv.>?= @ L  1 7
=& kHJ[[/0D  1JD = = " "I [[Wl3[[VZ0[[Xay1" 2 1 4 "rz   rZ  c                   (    \ rS rSrSr/ SQr/ SQrSrg)SkewKurtosisTestiR  r   r0  )gp=
ף?g?߾?gD9?gQI?g}?5^Ir   N)r   r   r   r   rG  rO  testmathworksr   r   rz   rw   r  r  R  s    OH<Mrz   r  c            	          \ rS rSr\\R                  R                  S\R                  \R                  /5      S 5       5       r\" SSS9\R                  R                  S5      \S 5       5       5       rS	 rS
 r\" SSS9\R                  R                  S5      \S 5       5       5       r\S 5       r\" SSS9\R                  R                  S5      \S 5       5       5       r\" SSS9\R                  R                  S5      \\R                  R                  S/ SQ5      \R                  R                  SSS/5      S 5       5       5       5       5       rSrg)TestSkewiX  stat_func                    UR                  / 5      n[        U5      (       a/  [        R                  " [        [
        S9   U" U5      nS S S 5        O[[        R                  R                  5        nUR                  [        S5        UR                  [        S5        U" U5      nS S S 5        [        WUR                  UR                  5      5        g ! , (       d  f       N4= f! , (       d  f       NE= f)Nr   Mean of empty slicezinvalid value encountered)rf   r+   rP  rQ  r   r   r   r  r   r   r   r0   rm   )rn   r  ro   rp   r   r   s         rw   test_empty_1dTestSkew.test_empty_1dY  s     JJrNB<<08MNqk ON --/3

>+@A

>+FGqk	 0
 	RZZ/0 ON 0/s   	C/5C#
C #
C1rC   r/  rE   rH   c                 X   [         R                  " UR                  U R                  5      5      n[	        X!R                  UR
                  5      5        [         R                  " UR                  U R                  5      5      n[	        X!R                  S5      SS9  [         R                  " UR                  U R                  5      SS9n[	        X!R                  S5      SS9  [         R                  " UR                  U R                  5      5      n[	        X!R                  S5      SS9  g )Ng7l*ҿ绽|=r3  r   biasg2۠ۿr   )ri   skewrf   rG  r/   rm   r  rO  )rn   ro   rq   s      rw   test_skewnessTestSkew.test_skewnessh  s     JJrzz$"6"678::bff-. JJrzz$"4"456::&78uEJJrzz$"4"45A>::&89FJJrzz$--01::c?7rz   c                    [         R                  " S5      n[         R                  US'   [         R                  " SS9   [	        [
        R                  " U5      [         R                  5        S S S 5        [	        [
        R                  " USS9S5        [        [        [
        R                  USS9  [        [        [
        R                  US	S9  g ! , (       d  f       Nj= f)
Nr   r8   r}  r~  r   r   r   r   r   )	r   r   rm   r  r   ri   r  r   r   ru  s     rw   ry  TestSkew.test_nan_policyy  s    IIcNvv![[*A/ +UZZf5r:j%**aGDj%**aHE	 +*s   /C
Cc                 V    [        [        R                  " [        S5      5      S5        g )Nr\   r   )r   ri   r  r   rh  s    rw   test_skewness_scalarTestSkew.test_skewness_scalar  s    UZZr
+S1rz   c                 <   UR                  S5      nUR                  US5      nUR                  US'   [        R                  " SS9   [
        R                  " USS9nS S S 5        [        WUR                  SUR                  /5      5        g ! , (       d  f       N6= f)	Nr   r}  r  r}  r~  r   rV   r   )	r   rk   rm   r   r  ri   r  r0   rf   )rn   ro   r9  rp  s       rw   test_skew_propagate_nan TestSkew.test_skew_propagate_nan  ss     IIbMJJq'"&&$[[*

11%A +2::q"&&k23 +*s   B
Bc                    [         R                  " [        SS9   UR                  S/S-  5      n[	        [
        R                  " U5      UR                  UR                  5      5        [	        [
        R                  " US-  5      UR                  UR                  5      5        [	        [
        R                  " US-  5      UR                  UR                  5      5        [	        [
        R                  " USS9UR                  UR                  5      5        UR                  S/S	-  5      n[	        [
        R                  " U5      UR                  UR                  5      5        S
UR                  SS5      S-  -   n[	        [
        R                  " U5      UR                  UR                  5      5        S S S 5        g ! , (       d  f       g = f)NPrecision loss occurredr   9ѿr\   g      CFr  g,@r6   r         r3   rb  )	rP  rQ  r   rf   r0   ri   r  rm   r   rn   ro   r9  s      rw   test_skew_constant_value!TestSkew.test_skew_constant_value  s,    \\.0IJ

K=+,AEJJqM2::bff+=>EJJqx0"**RVV2DEEJJqx0"**RVV2DEEJJqu5rzz"&&7IJ 

D6!8$AEJJqM2::bff+=>RYYsA&u,,AEJJqM2::bff+=> KJJs   FG
Gc                 "   [         R                  " [        SS9   [        R                  R                  S5      nUR                  UR	                  SS95      nSUS S 2S4'   [        R                  " U5        S S S 5        g ! , (       d  f       g = f)Nr  r   l   :"z` )r  r\   r  )\(?r   )	rP  rQ  r   r   r  r  rf   ri   r  )rn   ro   r  r9  s       rw   test_precision_loss_gh15554$TestSkew.test_precision_loss_gh15554  se     \\.0IJ))''4C

3::9:56AAadGJJqM	 KJJs   AB  
BrW   rb   r   r1   Nr  FTc                    ^ [         R                  R                  S5      nTR                  UR                  S5      5      nU4S jn[        R
                  " XRUS9nU" XRUS9n[        Xx5        g )N   f#"r  c                   > Uc  T	R                  U S5      n Sn[        U 5      nUR                  XSS9nUR                  X-
  S-  US9nUR                  XS9nXVS-  -  nU(       d"  U R                  U   nXxS-
  U-  S-  US	-
  -  -  nU$ )
Nr  r   Tr  r2   rV   r   r:   rm  )rk   r)   rl   r   r  )
r9  rW   r  r   rl   mu3r   r   r  ro   s
            rw   skewness-TestSkew.test_vectorization.<locals>.skewness  s    |JJq%(%a(G<<t<<D,,1}4,8C++a++Cq.CGGDMSA#-S99Jrz   )rW   r  )r   r  r  rf   ri   r  r/   )	rn   ro   rW   r  r  rp   r  r   r  s	    `       rw   test_vectorizationTestSkew.test_vectorization  s[     ii##M2JJszz),-	 jjD1q$/!rz   r   N)r   r   r   r   r'   rP  r  r  ri   r  kurtosisr  rH   r  r  ry  r  r  r  r  r  r   r   rz   rw   r  r  X  s   [[Z%**enn)EF1 G 1 kHJ[[/08  1J8F2 kHJ[[/04  1J4 ? ? kHJ[[/0  1J kHJ[[/0[[V%56[[VeT]3" 4 7  1J"rz   r  c            
          \ rS rSr\" SSS9\R                  R                  S5      \S 5       5       5       r	S r
S rS	 r\S
 5       r\" SSS9\R                  R                  S5      \\R                  R                  S/ SQ5      \R                  R                  SSS/5      \R                  R                  SSS/5      S 5       5       5       5       5       5       rSrg)TestKurtosisi  rC   r/  rE   rH   c                 @   [         R                  " UR                  U R                  5      5      nUR	                  U5      (       d   e[         R                  " UR                  U R
                  5      SSSS9n[        X!R                  S5      5        [         R                  " UR                  U R
                  5      SSS9n[        X!R                  S5      5        [         R                  " UR                  U R                  5      SS5      n[        X!R                  S5      5        UR                  S5      nUR                  US:H  UR                  UR                  5      U5      n[        [         R                  " U5      UR                  UR                  5      5        g )	Nr   r   fisherr  gO߻S@gx|N@g=
ףp=?r   r7   )ri   r  rf   rG  r  r  r/   rO  r   rP  rm   r0   )rn   ro   rq   rp   s       rw   test_kurtosisTestKurtosis.test_kurtosis  s    NN2::d&:&:;<xx{{{ NN2::d&8&891QQO::o67 NN2::d&8&89!!L::&789NN2::dmm4a;::d+,IIcNHHQ!VRZZ/3q)2::bff+=>rz   c                    [         R                  " S5      n[         R                  US'   [        [        R
                  " USS9S5        [        [        [        R
                  USS9  [        [        [        R
                  USS9  g )Nr   r8   r   r   Gzr   r   )r   r   rm   r   ri   r  r   r   ru  s     rw   test_kurtosis_nan_policy%TestKurtosis.test_kurtosis_nan_policy  sU    IIcNvv!ENN1@)Lj%..!Hj%..!Irz   c                 v    [        [        [        R                  " / SQ5      5      [        R
                  5        g )Nr  )r   typeri   r  r   r   rh  s    rw   test_kurtosis_array_scalar'TestKurtosis.test_kurtosis_array_scalar   s    T%..34bjjArz   c                 &   [         R                  " S5      R                  SS5      R                  [        5      n[         R
                  US'   [        R                  " USSS9n[         R                  R                  US[         R
                  /S	S
9  g )Nr7   r1   rb   r  r   r  r  g(\r2  r3  )
r   r   rk   r  r  rm   ri   r  r  r   )rn   r9  r~  s      rw   test_kurtosis_propagate_nan(TestKurtosis.test_kurtosis_propagate_nan  si     IIaL  B'..u5&&$NN11=


""1ubffoE"Brz   c           	          UR                  S/S-  5      n[        R                  " [        SS9   UR	                  [
        R                  " USS95      (       d   eUR	                  [
        R                  " U[        S5      -  SS95      (       d   eUR	                  [
        R                  " U[        S5      -  SS95      (       d   eUR	                  [
        R                  " USSS95      (       d   e S S S 5        g ! , (       d  f       g = f)	Nr  r\   r  r   F)r  l           r  )rf   rP  rQ  r   r  ri   r  r  r  s      rw   test_kurtosis_constant_value)TestKurtosis.test_kurtosis_constant_value  s     JJ}R'(\\.0IJ88ENN1U;<<<<88ENN1uU|+;EJKKKK88ENN1uU|+;EJKKKK88ENN1UGHHHH	 KJJs   CC??
DrW   r  r  FTr  c                    ^ [         R                  R                  S5      nTR                  UR                  S5      5      nU4S jn[        R
                  " XbX4S9nU" XbX4S9n	[        X5        g )Nr  r   c                 b  > Uc  T
R                  U S5      n Sn[        U 5      nUR                  XSS9nUR                  X-
  S-  US9nUR                  XSS9nU(       a  XgS-  -  S	-
  nO8U R                  U   n	U	S
-
  U	S-
  U	S	-
  -  -  U	S
-   U-  US-  -  S	U	S
-
  -  -
  -  nU(       a  U$ US	-   $ )Nr  r   Tr  r3   rV   rW   r   r1   r2   r   )rk   r)   rl   r   r  )r9  rW   r  r  r   rl   mu4mu2r   r  ro   s             rw   r  1TestKurtosis.test_vectorization.<locals>.kurtosis$  s    |JJq%(%a(G<<t<<D,,1}4,8C++aq+9CFlQ&GGDMs!!}-!a%3sAv1E1Q31OP !3-cAg-rz   )rW   r  r  )r   r  r  rf   ri   r  r/   )
rn   ro   rW   r  r  r  rp   r  r   r  s
    `        rw   r  TestKurtosis.test_vectorization  s[     ii##M2JJszz),-	.( nnQDq$>!rz   r   N)r   r   r   r   rH   rP  r  r  r'   r  r  r  r  r  r  r  r   r   rz   rw   r  r    s    kHJ[[/0?  1J?>JBC I I kHJ[[/0[[V%56[[VeT]3[[Xt}5" 6 4 7  1J"rz   r  c           	      8   [        SSS9n[        R                  " SSS9nU " [        R                  " [        R
                  XS95      n/ n[        R                  " 5          [        R                  " S5        [        [        UR                  5      5       H  n[        R                  " [        5         [        R                   " USUS9n[        R"                  " US	:  5      (       a@  [        R"                  " [        R$                  " U5      5      (       a  UR'                  U5        S S S 5        M     S S S 5        [(        R*                  " U5        U " [(        R,                  R/                  U5      5      nX54$ ! , (       d  f       M  = f! , (       d  f       N^= f)
NF)	allow_nanallow_infinityr   r1   )min_dimsmin_side)rX  elementsr  errorro  r   )dictnpstarray_shapesarraysr   r   rP  rQ  rR  r  r  r  
contextlibsuppress	Exceptionri   rc  rc  rf  r6  
hypothesisassume
strategiessampled_from)drawr  r  r  ok_axesrW   r   s          rw   ttest_data_axis_strategyr  =  s    eE:Hq15E "**xMND G 
	 	 	"g&#djj/*D$$Y/ll4qt<66#'??rvvbkk#.>'?'?NN4( 0/ + 
# g 
%%227;<D: 0/ 
#	"s&    AF2A5E9'F9
FF
FUses NumPy for pvalue, CIr!  rF   c                      \ rS rSr/ SQr/ SQrSrSrSrSr	Sr
S	rS
rSr\	S-  rS\	S-  -
  rS rS rS r\R(                  R+                  S/ SQ5      S 5       rS r\R(                  R0                  \R4                  " \R6                  R9                  SS5      \" 5       S9\R(                  R+                  SSS/5      S 5       5       5       rSrg)TestStudentTesti\  r>  r   r   )r   r   rm  r   r   gMXzg4/?gMXzgFX5t?gMXz?r1   r   c                 .   [        5        n[        R                  " SSS9   UR                  [        S5        [        U5      (       d  UR                  S5      OSn[        R                  " US5      u  pES S S 5        S S S 5        [        WUR                  UR                  5      5        [        WUR                  UR                  5      5        [        R                  " UR                  U R                  5      S5      u  pE[        XAR                  U R                  5      5        [        XQR                  U R                  5      5        [        R                  " UR                  U R                  5      S5      nSn[        XgUS9  [        R                  " UR                  U R                   5      S5      u  pE[        XAR                  U R"                  5      5        [        XQR                  U R$                  5      5        [        R                  " UR                  U R                  5      S	5      u  pE[        XAR                  U R&                  5      5        [        XQR                  U R(                  5      5        [        R                  " UR                  U R                  5      S
5      u  pE[        XAR                  U R*                  5      5        [        XQR                  U R,                  5      5        g ! , (       d  f       GN= f! , (       d  f       GN= f)Nr}  r  divide!Degrees of freedom <= 0 for slicer   r1  r   r*  r)  ro   r   rm  )r   r   r  r   r   r+   rf   ri   ttest_1sampr0   rm   X1r/   T1_0P1_0r   X2T2_0P2_0T1_1P1_1T1_2P1_2)rn   ro   r   r9  trT  r   r,  s           rw   test_onesampleTestStudentTest.test_onesampler  s    CHX>JJ~'JK&.rll

2A$$Q+DA ? !
 	2::bff-.2::bff-.  DGG!4b9::dii01::dii01

477 3R8,
C3  DGG!4b9::dii01::dii01  DGG!4b9::dii01::dii01  DGG!4b9::dii01::dii019 ?> ! s#   LAK34L3
L	=L
Lc           	         [        U5      (       dZ  UR                  SSSUR                  /5      nSn[        R                  " [
        US9   [        R                  " USSS9  S S S 5        g [        R                  R                  SS	S
SS9n[        R                  US'   [        R                  " SS9   [        [        R                  " US5      [        R                  [        R                  45        [        [        R                  " USSS9S5        [        [        [        R                  USSS9  [        [        [        R                  USSS9  S S S 5        g ! , (       d  f       g = f! , (       d  f       g = f)Nr   rm  r1  %Use of `nan_policy` and `keepdims`...r   r   r   r4   r\   3   it r  r  r  r  r   r}  r~  rO   )g̈́^Bg/kCm?r   r   )r+   rf   rm   rP  r   NotImplementedErrorri   r  rG  r  r   r  r	   r   r   r   )rn   ro   rp   r  s       rw   test_onesample_nan_policy)TestStudentTest.test_onesample_nan_policy  s   ||

BB/0A=G2'B!!!RF; CJJNNq'NJ"[[*u00C8266266:JK%e&7&736&R&QS*e&7&7CGT*e&7&7C%-/ +* CB +*s   E2BE*
E'*
E8c                    Sn[         R                  " [        US9   [        R                  " UR                  U R                  5      SSS9  S S S 5        [        R                  " UR                  U R                  5      SSS9u  p4[        XAR                  U R                  5      5        [        X1R                  U R                  5      5        [        R                  " UR                  U R                  5      SSS9u  p4[        XAR                  U R                  5      5        [        X1R                  U R                  5      5        g ! , (       d  f       GN= f)	N8`alternative` must be 'less', 'greater', or 'two-sided'.r   r   r  r  r   r~  r  )rP  r   r   ri   r  rf   r  r/   P1_1_lr  P1_1_g)rn   ro   r  r  rT  s        rw   test_1samp_alternative&TestStudentTest.test_1samp_alternative  s    L]]:W5bjj127K 6   DGG!4bfM::dkk23::dii01  DGG!4biP::dkk23::dii01 65s   0E
Er  r=  c                    [         R                  R                  S5      nSnUR                  USSS9nUR                  5       n[	        U5      (       a  UR
                  OUR                  nUR                  XWS9nUR                  XgS9nSS/S	[         R                  /[         R                  * S
/S.n[        R                  " XVUS9n	U	R                  SS9n
[        U
R                  UR                  X   S   5      5        [        U
R                  UR                  X   S   5      5        [        U	R                   UR                  US-
  5      5        g )Nl   <PleH r\   r;   r1   r  r  r  rZ  gÍ]?g$(}w@gS1?g]@r|  r  r~  )popmeanr  333333?confidence_levelr   r   )r   r  r  r  r,   r   r   rf   r  ri   r  ro  r/   rr  rs  r0   df)rn   ro   r  r  r  rp   r  rX  r  r   r  s              rw   test_1samp_ci_1d TestStudentTest.test_1samp_ci_1d  s     ii##$78JJA3aJ0**, 'rll



JJqJ&**W*2/1CD-rvv6!235 L$$d$;

3+;A+> ?@C,<Q,?!@A

1Q30rz   c                     [         R                  " UR                  S5      S5      nSn[        R                  " [
        US9   UR                  SS9  S S S 5        g ! , (       d  f       g = f)Nr   r   4`confidence_level` must be a number between 0 and 1.r   r\   r  )ri   r  r   rP  r   r   ro  )rn   ro   r   r  s       rw   test_1samp_ci_iv TestStudentTest.test_1samp_ci_iv  sL    		#3H]]:W5##R#8 655s   A
A)r2  g?)alpha	data_axisr~  r  c                    Uu  pVUR                  U5      n[        R                  " USX6S9nUR                  US9u  pUS:X  a  UOU	n
[	        U5      nUR                  XS9n
[        R                  " XZX6S9n[        UR                  5      nUR                  U5        UR                  UR                  SU-
  UR                  S9U5      n[        UR                  U5        g )Nr   r  r  r  rV   r   rZ  )rf   ri   r  ro  r)   rI  r&  r  r  r]  r   r/   r)  )rn   r$  r%  r  ro   r  rW   r   lr  r  r   r  r  s                 rw   test_pvalue_ciTestStudentTest.test_pvalue_ci  s     
zz$b,7D&&&>"i/!Q!!$%%g%9;RTZZ 		$oobjj5

jCUK

C(rz   r   N) r   r   r   r   r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  rP  r  r  r  r"  r^  r  givenr  floatsr  r(  r   r   rz   rw   r  r  \  s     
B	BDDDDDDDDAXF$(^F2@/(2 [[],LM1 N109 [[J1188H 8 :<[[]VY,?@) A< )rz   r  c                      \ rS rSrS r\R                  R                  S/ SQ5      S 5       r\R                  R                  S/ SQ5      S 5       r	\R                  R                  S/ SQ5      S	 5       r
\R                  R                  S/ S
Q5      S 5       r\R                  R                  S/ SQ5      S 5       r\R                  R                  S/ SQ5      S 5       r\R                  R                  S/ S
Q5      S 5       r\R                  R                  SS/ SQ4S/ SQ4S/ SQ4S/ SQ4/5      S 5       r\R                  R                  SS/ SQ4S/ SQ4S/ SQ4S/ SQ4/5      S 5       rS/ S\R$                  4S\R$                  /S\R$                  4S\R$                  // SQ\R$                  \R$                  \R$                  /4SSS/SS\R$                  /SS \R$                  /4S!SS\R$                  // SQ/ S"Q4S!SS/S#S\R$                  /S#S\R$                  /4S!\R$                  \R$                  // SQ\R$                  \R$                  \R$                  /4/r\R                  R                  S$\5      S% 5       rS&SSS'\R$                  // S(QS)4S&/ S(QSSS'\R$                  /S)4/r\R                  R                  S*\5      S+ 5       r\R                  R                  S,/ S-Q5      S. 5       rS/rg0)1TestPercentileOfScorei  c                 .    [         R                  " U0 UD6$ r  )ri   percentileofscore)rn   argskwargss      rw   fTestPercentileOfScore.f  s    &&777rz   zkind, result))r  r  )rl   #   strictr  )weakr  c                 B    / SQn[        U R                  USUS9U5        g )N
r   r1   r2   r3   r4   r5   r6   r7   r8   r\   r3   kindr   r2  rn   r;  r  r9  s       rw   test_unique!TestPercentileOfScore.test_unique  s"    
 ,TVVAqtV,f5rz   ))r  r  )rl   r  r5  )r7  r   c                 B    / SQn[        U R                  USUS9U5        g )N)
r   r1   r2   r3   r3   r4   r5   r6   r7   r8   r3   r:  r<  r=  s       rw   test_multiple2$TestPercentileOfScore.test_multiple2  "    
 +TVVAqtV,f5rz   ))r  r   )rl   r  r5  )r7  r9  c                 B    / SQn[        U R                  USUS9U5        g )N)
r   r1   r2   r3   r3   r3   r4   r5   r6   r7   r3   r:  r<  r=  s       rw   test_multiple3$TestPercentileOfScore.test_multiple3  rC  rz   ))r  r  )rl   r  r5  )r7  r  c                 B    / SQn[        U R                  USUS9U5        g )N)
r   r1   r2   r4   r5   r6   r7   r8   r\   r]   r3   r:  r<  r=  s       rw   test_missing"TestPercentileOfScore.test_missing  s"    
 -TVVAqtV,f5rz   c                 B    / SQn[        U R                  USUS9U5        g )N
r\   r  r  r  r   r9  F   r=  r  r  r  r:  r<  r=  s       rw   r#  (TestPercentileOfScore.test_large_numbers  s"    
 6TVVArV-v6rz   c                 B    / SQn[        U R                  USUS9U5        g )N)
r\   r  r  r  r  r  r   r9  rL  r=  r  r:  r<  r=  s       rw   test_large_numbers_multiple32TestPercentileOfScore.test_large_numbers_multiple3  s"    
 5TVVArV-v6rz   c                 B    / SQn[        U R                  USUS9U5        g )N
r\   r  r  r   r9  rL  r=  r  r  n   r  r:  r<  r=  s       rw   test_large_numbers_missing0TestPercentileOfScore.test_large_numbers_missing  s"    
 7TVVArV-v6rz   r  )r   r\   r  r  rl   )r   r4   _   r  r6  )r   r   r  r  r7  c                 F    / SQn[        U R                  U/ SQUS9U5        g )NrR  )r   r\   rS  r  r:  r<  r=  s       rw   test_boundaries%TestPercentileOfScore.test_boundaries&  s#    
 7TVVA0tV<fErz   )r   r\   r  )r   r4   rV  )r   r   r  c           
          SSSSSSSSS	[         R                  7/
n[        U R                  U[         R                  * S[         R                  7/US
9U5        g )Nr   r1   r2   r3   r4   r5   r6   r7   r8   r:  )r   r  r   r2  r=  s       rw   test_infTestPercentileOfScore.test_inf.  sP    
 1aAq!Q0TVVARVVG44V@&Irz   r  r   r  r1   r   r  r   )r   r   r  r   zpolicy, a, score, resultc                 8    [        U R                  X#US9U5        g )Nr   r<  )rn   policyr9  r  r  s        rw   test_nans_ok"TestPercentileOfScore.test_nans_ok>  s    TVVAV8&Arz   r   r2   r  r   zpolicy, a, score, messagec                 t    [        [        US9   U R                  X#US9  S S S 5        g ! , (       d  f       g = f)Nr   r   )r   r   r2  )rn   r^  r9  r  r  s        rw   test_nans_fail$TestPercentileOfScore.test_nans_failI  s(    :W5FF1F/ 655s   )
7r  ))r5   rF  r1   r   r2   )r1   r   r   r2   c                     [         R                  " / SQ5      nUR                  U5      nUS-  n/ SQn[        U R	                  X#SS9U5        g )N)r   r   r1   r2   r3   r4   r\   r9  r  r:  )r   r   rk   r   r2  )rn   r  r9  rw  resultss        rw   test_ndTestPercentileOfScore.test_ndN  sF     HH'(5!)+TVVAFV3W=rz   r   N)r   r   r   r   r2  rP  r  r  r>  rA  rE  rH  r#  rO  rT  rX  r[  r   rm   casesr_  rb  rg  r   r   rz   rw   r-  r-    sf   8 [[^ .< =6	=6 [[^ .< =6	=6 [[^ .< =6	=6 [[^ .< =6	=6 [[^ .< =7	=7 [[^ .< =7	=7 [[^ .< =7	=7 [[^v7H.I/5.G/7.I/57H.I.K LF	LF [[^v|.D/5z.B/7.D/5|.D.F GJ	GJ 2q"&&)BFF8Q/BFF8Y0HIAq6Aq"&&>BRVV3DEq!RVVni>q!fq!RVVnq"bffo>rvvrvv&	BFFBFFBFF3KLNE [[7?B @B 
1aBFF#Y	(	*	)aArvv.	(	*E [[8%@0 A0 [[W ' >>rz   r-  Case)f_obsf_exprN  rW   chi2r  mod_logcr)r3   r7   r^   r7   r3   r1   r:   r^   r;   r7   rm  r5  gfx(@)r1   r   r^   r1   r~  r   r         ?g{T4@)r2   r4   r6   r8   r   r   r   c                   D   \ rS rSrS r\R                  R                  S\5      \R                  R                  S/ SQ5      S 5       5       r	S r
S r\R                  R                  S\5      \R                  R                  S/ S	Q5      S
 5       5       rS rS rS rSrg)TestPowerDivergencei  c           	         UR                  S5      R                  nUR                  XS9nUb  UR                  X(S9OUnUc  [        U5      n	O4[        U5      n
Ub  U
R	                  X5      OU4nUS   R
                  U   n	[        5        nUR                  [        S5        [        R                  " XUXES9u  p[        XR                  XhS95        US:X  d  US:X  a0  [        R                  " XUUS9u  p[        XR                  XhS95        S S S 5        [        R                   " U5      n[        R                  R                  R!                  UU	S-
  U-
  5      n[        WUR                  XS95        g ! , (       d  f       Nn= f)	Nr   rZ  r   r  rk  rl  rN  rW   lambda_r   pearson)rk  rl  rN  rW   )rf   rX  r-   r)   broadcast_arraysr  r   r   r   ri   power_divergencer/   	chisquarer   distributionsrm  sf)rn   rk  rl  rN  rW   rv  expected_statro   rX  num_obsr   r  r   statrT  
expected_ps                   rw   check_power_divergence*TestPowerDivergence.check_power_divergence  s_   

2$$

5
.272C

5
.<enG%e,G@E@Qg..u<!8 Qiood+G CJJ~'<=,,&+t%)<GD D**]*"HI!|w)3///35jjj&LM ! zz$((--00181t1CE
2::j:>?! ! s   BE77
Fcaselambda_stat))Nrm  rw  rm  )r   rm  log-likelihoodr  mod-log-likelihoodrn  cressie-readro  r5  ro  c           	          Uu  pE[        X5      nU R                  UR                  UR                  UR                  UR
                  XFU5        g r  )r[  r  rk  rl  rN  rW   rn   r  r  ro   rv  attrr}  s          rw   rF  TestPowerDivergence.test_basic  sA     $+##DJJ

DIItyy$+B	@rz   c           
      t   [         S   n[         S   n[        R                  " UR                  UR                  45      n[        R                  " [        R                  " UR                  5      [        R
                  " UR                  5      -  UR                  45      nUR                  U5      nUb  UR                  U5      OUnU R                  XESSSUR                  UR                  /US9  U R                  XESSSUR                  UR                  /US9  U R                  XESSSUR                  UR                  /US9  U R                  XESSSUR                  UR                  /US9  UR                  UR                  UR                  5      S5      nU R                  US SS SUR                  US9  g )	Nr   r   rw  r  r  r  r  r1  )power_div_1d_casesr   rC  rk  	ones_likerl   rl  rf   r  rm  r  rn  ro  rk   )rn   ro   case0case1rk  rl  f_obs_reshapes          rw   r  TestPowerDivergence.test_axis  s   "1%"1%		5;;45		2<<4RWWU[[5II ;;( ) 

5!%*%6

5!E##Q5::uzz2r 	$ 	; 	##Q%))UYY!7B 	$ 	@ 	##Q#emmU]]%C 	$ 	L 	##Q%((3 	$ 	<
 

2::ekk#:FC##dAt%** 	$ 	-rz   c                    [         S   n[         S   n[        R                  " UR                  UR                  45      R                  n[        R                  " [        R
                  " UR                  5      [        R                  " UR                  5      -  UR                  45      R                  nUR                  UR                  /nUR                  S5      R                  nUR                  XGS9nUR                  XWS9nUR                  XgS9nUR                  S/S//5      n[        R                  " XEUS9u  p[        X5        [        R                  " XEUS   S9u  p[        R                  " XEUS   S9u  p[        U5      nUR                  XR                   S S 24   XR                   S S 24   4SS9n[        U
U5        g )	Nr   r   r   rZ  rM  r  r  rV   )r  r   rC  rk  r  r  rl   rl  rm  rf   rX  ri   ry  r/   r)   r  rg  )rn   ro   r  r  rk  rl  expected_chi2rX  rN  r  rT  stat0p0stat1p1r   r  s                    rw   test_ddof_broadcasting*TestPowerDivergence.test_ddof_broadcasting  s    #1%"1%		5;;4577		2<<4RWWU[[5II ;;( ))* 	 UZZ0

2$$

5
.

5
.

=
> zzA3*%((DA, **5d4jI	**5d4jI	!%(^^R(:%;%'(:%;%=)* $ ,
 	:&rz   )r  r  r  r  r  c           
          Uu  pE[        X5      n[        R                  " 5          U R                  UR                  UR
                  UR                  UR                  XFU5        S S S 5        g ! , (       d  f       g = fr  )r[  rP  rQ  r  rk  rl  rN  rW   r  s          rw   test_empty_cases$TestPowerDivergence.test_empty_cases  sY     $+$$&''

DJJ		499, '&&s   ?A--
A;c                 6   [         S   R                  n[         S   R                  n[         S   R                  n[         S   R                  nUR                  S5      R                  nUR                  X&S9n[        R                  " X#UUSS9nSn[        XxUS9  g )Nr   r   rZ  rw  ru  r  r  )
r  rk  rl  rN  rW   rf   rX  ri   ry  r   )	rn   ro   rk  rl  rN  rW   rX  r   r,  s	            rw   'test_power_divergence_result_attributes;TestPowerDivergence.test_power_divergence_result_attributes  s    "1%++"1%++!!$))!!$))

2$$

5
. $$5D*.	C,
C3rz   c                 @   UR                  SS/SS//5      nUR                  SS/SS//5      nSn[        R                  " [        US	9   [        R
                  " X!R                  SS
/5      S9  S S S 5        [        R                  " [        US	9   [        R
                  " X#SS9  S S S 5        [        R
                  " X#S9u  pV[        XQR                  SS/5      5        [        XaR                  SS/5      5        g ! , (       d  f       N= f! , (       d  f       Nn= f)Nr   r        >@rO   rL  g     A@g      9@For each axis slice...r         N@rk  rl  r   )rk  rl  rW   g̑m@gUUU@gj^4;?g4;?)rf   rP  r   r   ri   ry  r/   )rn   ro   rk  rl  r  r  r  s          rw   test_power_divergence_gh_122822TestPowerDivergence.test_power_divergence_gh_12282'  s    

S#Jc
34

RISz23*]]:W5""jj#s6LM 6]]:W5""!D 6++%E
jj*j)ABCjj*j)ABC 6555s   
&C>D>
D
Dc           	         UR                  / SQ5      nSnUR                  SUR                  S   S-   5      nUR                  UR	                  U5      UR	                  UR                  X4-  5      5      -  5      nUR                  XSU-  -   5      n[        U5      nUR                  X'R                  S S 24   XgR                  S S 24   45      R                  nUR                  / SQ5      n	UR                  U	S5      n	[        U	R                  S   5       H>  nXS4   XS4   p[        R                  " US S 2S4   US S 2S4   U
S9u  p[        XS	S
9  M@     g )N)rL  r        ,@g      1@rO   r  r   r   r   r   r   r   r  r1  r   r   r   r   g*kqr   r   ) g      $g    @r|  g     r@r  gffffffP@g       gLD@rp  g      A@r>  g     =@ro  g     :@r   g8@r:   gffffff7@gq=
ףp?g7@r   g333336@r;   g6@rm  gfffff6@r1  g8@rO   g     A@r   g     j@)rb   r1   r   rv  g{Gzt?r  )rf   r   r  r  rM  expr)   r  rg  r  rk   r  ri   ry  r/   )rn   ro   obsbetar  r$  expected_countsr   table4table5rv  r}  r  rT  s                 rw   /test_power_divergence_against_cressie_read_dataCTestPowerDivergence.test_power_divergence_against_cressie_read_data4  sG    jj @ AIIb#))A,+,rvvc{RVVBFF46N%;;<&&a0 "#&__a%7!8!0!1C!D!F GGHq 	   & FG,v||A'A%+qD\6Q$<],,VAaC[&1+5<>GDDd;	 (rz   r   N)r   r   r   r   r  rP  r  r  r  rF  r  r  power_div_empty_casesr  r  r  r  r   r   rz   rw   rs  rs    s    @B [[V%78[[]	./@	/ 9
@-:#'J [[V%:;[[]	./,	/ <
,4D.<rz   rs  c                   h    \ rS rSrS rS r\R                  R                  SSS/5      S 5       r	Sr
g	)
TestChisquareie  c                     [        [        SS9   UR                  SS/5      nUR                  SS/5      n[        R                  " X#S9  S S S 5        g ! , (       d  f       g = f)Nr  r   r   r  r  r  r  )r   r   rf   ri   rz  )rn   ro   rk  rl  s       rw   test_chisquare_12282a#TestChisquare.test_chisquare_12282ag  sL     :-EFJJSz*EJJSz*EOO%5 GFFs   ;A
A!c                    [         R                  R                  S5      nSnUR                  SSUS9nUR	                  U5      nUR                  U5      nUR                  XTR                  S9n[        R                  " XTSSS	9nXT-
  UR                  U5      -  nUR                  US
-  5      n[        UR                  U5        [        UR                  X8R                  S95      n	[        UR                  U	R                  U5      5        g )Nl   *m{m r\   r  r%  r  rZ  rb   F)rk  rl  rN  	sum_checkr1   )r   r  r  r  poissonrf   rX  ri   rz  r6  rM  r/   r*  r%   r)  r|  )
rn   ro   r  r  lamrp   r   r-  r*  r  s
             rw   test_chisquare_12282b#TestChisquare.test_chisquare_12282bp  s     ii##$45kk$1k-KKjjoJJq		J*ooArUKW$FF1a4L	y1A__=>

BEE)$45rz   zn, dtype)r  r&  )i@B r  c           	      Z   [        X25      nUR                  US/US9nUR                  US-  US-  /US9n[        R                  " XE5      nUu  px[	        XsR                  XR                  S5      R
                  S9SS9  [        UR                  U5        [        UR                  U5        g )Nr   rZ  r1   r   vIh%<=r  )	r[  rf   ri   rz  r/   rX  r0   r*  r)  )	rn   r  rX  ro   r  r  r   r  rT  s	            rw   #test_chiquare_data_types_attributes1TestChisquare.test_chiquare_data_types_attributes  s     "jj!Quj-jj!q&!q&)j7ooc'jj**R.2F2FjGeTt,

A&rz   r   N)r   r   r   r   r  r  rP  r  r  r  r   r   rz   rw   r  r  e  s8    66& [[Z.:L)MN
' O
'rz   r  c                   \    \ rS rSr\R
                  R                  S5      S 5       rS rSr	g)TestChisquareMAi  r@  c           
         [         R                  " / SQ/ SQ/5      R                  n[         R                  " / SQ/ SQ/5      R                  n[         R                  R	                  X5      n[         R                  " SS/5      n[         R                  " SS[         R
                  " S5      -  S	[         R
                  " S
5      -  -   -  SS[         R
                  " S5      -  S[         R
                  " S5      -  -   -  /5      n[        R                  R                  n[        R                  " U5      u  px[        R                  " Xt5        [        R                  " XR                  UUR                  SS9S-
  5      5        [        R                  " USS9u  p[        R                  " XSS9  [        R                  " XR                  UUR                  SS9S-
  5      5        [        R                  " UR                  SS9u  px[        R                  " Xt5        [        R                  " XR                  UUR                  R                  SS9S-
  5      5        [        R                  " UR                  SSS9u  p[        R                  " XSS9  [        R                  " XR                  UUR                  SS9S-
  5      5        [         R                  R                  / SQ/ SQS9n
[         R                  R                  / SQ/ SQS9n[        R                  " XS9u  ph[        R                  " US5        [        R                  " [         R                  R                  / SQ5      S S9u  px[!        [#        U[         R$                  5      5        [!        [#        U[         R$                  5      5        ['        US5        [)        U[        R                  R                  R                  SS5      5        [         R*                  " SS9   [-        5        nUR/                  [0        S 5        [        R                  " [         R                  R                  / 5      5      u  pxS S S 5        S S S 5        [!        [#        U[         R                  R2                  5      5        ['        UR4                  S!5        [!        UR6                  5        [         R                  R                  / / / /5      n[        R                  " U5      u  px[!        [#        U[         R                  R2                  5      5        [        R                  " U/ 5        [         R*                  " SS9   [-        5        nUR/                  [0        S 5        [        R                  " UR                  5      u  pxS S S 5        S S S 5        [!        [#        U[         R                  R2                  5      5        ['        UR4                  S"5        [!        [         R8                  " UR6                  5      5        g ! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       N= f! , (       d  f       N= f)#N)r7   r7   r       rb   )rb   rb   r2   r3   r4   )r   r   r   r   r   )r   r   r   r   r   g      8@r:   r1   r   r  rm  r2   r  r4   rk  r   rV   r   r  r  r  rS  )rW   rv  )r2   r4   r5   r  r\   )r   r   r   r   r   r  )r1   r3   r7   r\   r  )rl  r  r   r}  r~  r  r   r  )r   r   r  rc  r  r  ri   r{  rm  rz  matr	   r   r|  r  ry  r   r#  r   r   r   r  r   r   r   r  r  r  rc  )rn   r  r  mobsexpected_chisq
expected_grm  chisqrT  gobs1exp1r   empty3s                 rw   test_chisquare_masked_arrays,TestChisquareMA.test_chisquare_masked_arrays  sg    hh*,=>?AAxx/:;==uu!!#,4+.XXq#bffSk/Brvvc{N"BC !BFF4L.1RVVD\>"ABD E
 ""''??4(u5%%a151Ca1G*I 	J %%d4DE%%aR@%%a151Ca1G*I 	J ??4662u5%%a1511E1I*K 	L%%dff1>NO%%aR@%%a151Ca1G*I 	J uu{{,?{Cuu{{,?{C//$3 	t_5 ??255;;w#7dC
5"**-.
1bjj)*UC Au2277::3BC [[*"$

>+@A ??255;;r?; % + 	
5"%%"3"345U[["%

bBZ( ??6*
5"%%"3"345ub) [[*"$

>+@A ??6884 % +
 	
5"%%"3"345U[[$'uzz"#1 %$ +*& %$ +*sI   	X-AX X-Y%9X?Y
X*	%X--
X<?
Y		Y
Yc                    [         R                  " / SQ5      n[         R                  R                  U5      nSn[        R
                  " [        US9   [        R                  " U5        S S S 5        [        R
                  " [        US9   [        R                  " X5        S S S 5        g ! , (       d  f       NG= f! , (       d  f       g = f)Nr  z8`power_divergence` and `chisquare` support for masked...r   )	r   rf   rc  r  rP  rQ  DeprecationWarningri   rz  )rn   r9  rc  r  s       rw   test_deprecation_warning(TestChisquareMA.test_deprecation_warning  s|    JJ|$UU"L\\,G<OOB =\\,G<OOA" =< =<<<s   B+B<+
B9<
C
r   N)
r   r   r   r   rP  r  r  r  r  r   r   rz   rw   r  r    s,    [[ <=H$ >H$T#rz   r  c            	         [        / SQ5      [        / SQ5      [        / SQ5      [        / SQ5      /n [        / SQ5      [        / SQ5      [        / SQ5      [        / SQ5      /n[        / S	Q5      [        / S
Q5      [        / SQ5      [        / SQ5      /n[        [        R                  " U S   U S   U S   U S   5      S5        [        [        R                  " US   US   US   US   5      S5        [        [        R                  " US   US   US   US   5      S5        [	        [
        [        R                  US   US   5        Sn[        R                  " U 6 n[        XC5        [        [        R                  " U S   U S   U S   U S   5      S5        [        [        R                  " US   US   US   US   5      S5        [	        [
        [        R                  US   US   5        g )N)g"~j?g^I+?gI+?gjt?gMbX9?gʡE?x&?-?g?r   Gz?g+?gv?g9v?)g~jt?gx?gOn?r  g"~j?n?gK7A`?r  g7A`?r   bX9?gZd;O?g1Zd?gK?)gy&1?gzG?g`"?g!rh?g'1Z?gZd;O?grh|?gjt?gʡE?r   gzG?gS?gJ4?gʡE?)gK7?gh|?5?gl?g/$?g#~j?r  gQ?      ?g      ?r   r  g rh?g333333?
ףp=
?)r3   r2   r4   r2   r4   r2   r1   r4   r3   r3   r3   r2   )r1   r1   r   r1   r2   r   r1   r2   r1   r   r   r2   )r1   r3   r2   r2   r3   r2   r2   r3   r3   r   r1   r   )r2   r4   r3   r2   r3   r3   r2   r2   r2   r3   r3   r3   )r   g#@rB   r  g$@)g333333@g@g@r=   g@)r  r  r?   r   @)g!@g!@333333 @ffffff
@g333333"@r   r   r1   r2   )gNt$@gBv?)g
__2@g5"]i2?)g\(\%@g+ԋ?r  )r   r   ri   friedmanchisquarer   r   r   mstats)r  r  r  r,  r   s        rw   test_friedmanchisquarer    s   
  8 9
 9 :
 : ;
 9 :
;B )
*
)
*
)
*
)
*
,B &
'
%
&
%
&
%
&
(B
 e55beBqE"Q%1NDFe55beBqE"Q%1NFHe55beBqE"Q%1N9;*e55beBqEB )J

!
!2
&C( f66r!ube79!ubeEDF f66r!ube79!ubeE9; *f66r!uRUCrz   c                   @    \ rS rSrSr S
S jrS
S jrS rS rS r	Sr
g	)
TestKSTesti  zLTests kstest and ks_1samp agree with K-S various sizes, alternatives, modes.c                     [         R                  " USX%S9n[        R                  " X4/5      n[	        [        R                  " U5      XS9  g NrG  r  r  rS  )ri   kstestr   r   r   	rn   rp   r  expected_statisticexpected_probr  r  r  r  s	            rw   _testOneTestKSTest._testOne"  s9    a[L88/?@!"((6"2HNrz   c                     [         R                  " USX#S9n[         R                  " U[         R                  R                  X#S9n[        [        R                  " U5      XdS9  g r  )ri   r  ks_1samprG  cdfr   r   r   )rn   rp   r  r  r  r  result_1samps          rw   _test_kstest_and_ks1samp#TestKSTest._test_kstest_and_ks1samp(  sE    a[L~~a2=J!"((6"2LRrz   c                 |    [         R                  " SSS5      nSn[        R                  " US5      n[	        X25        g )Nrb   r   r8   r  rG  )r   r!  ri   r  r   rn   rp   r,  r   s       rw   test_namedtuple_attributes%TestKSTest.test_namedtuple_attributes.  s1    KKAq!,
ll1f%C,rz   c                    [         R                  " SSS5      nU R                  US5        [         R                  " SSS5      nU R                  US5        / SQnU R                  US5        U R                  USS	S
9  U R                  USS	S
9  g )Nrb   r   r8   r|  r  
r  Q?g333333g(\?Q?g(\ſg{GzgHzG?g\(\gGzr  r  r  r~  )r   r!  r  ru  s     rw   test_agree_with_ks_1samp#TestKSTest.test_agree_with_ks_1samp5  s    KKAq!%%a5KKR#%%a5N%%a5%%a%A%%ag%>rz   c                    [         R                  * SS[         R                  /n[        R                  " U[        R                  R
                  5      n[        R                  " U[        R                  R
                  SS9n[         R                  " [         R                  " U5      5      (       d   e[        X#5        [         R                  " UR                  5      (       a   e[         R                  " UR                  5      (       a   eg )Nr   r   T)_no_deco)r   r  ri   r  cauchyr  rc  rf  r   r  r*  r)  )rn   r  r   r  s       rw   test_pm_inf_gh20386TestKSTest.test_pm_inf_gh20386A  s     Arvv&ll4!1!12ll4!1!1DAvvbkk#&''''S88CMM****88CJJ'''''rz   r   NautorZ   )r   r   r   r   r   r  r  r  r  r	  r   r   rz   rw   r  r    s%    V ')OS-
?	(rz   r  c                       \ rS rSrSr SS jrS rS rS rS r	\
R                  R                  S\R                  \R                  /5      \
R                  R                  S	/ S
Q5      S 5       5       rSrg)TestKSOneSampleiO  zQ
Tests kstest and ks_samp 1-samples with K-S various sizes, alternatives, modes.
c                     [         R                  " U[         R                  R                  X%S9n[        R
                  " X4/5      n[        [        R
                  " U5      XS9  g )Nr  rS  )ri   r  rG  r  r   r   r   r  s	            rw   r  TestKSOneSample._testOneT  sA    5::>>{V88/?@!"((6"2HNrz   c                     [         R                  " SSS5      nSn[        R                  " U[        R                  R
                  5      n[        X25        g )Nrb   r   r8   r  )r   r!  ri   r  rG  r  r   r  s       rw   r  *TestKSOneSample.test_namedtuple_attributesZ  s9    KKAq!,
nnQ

/C,rz   c                 0   [         R                  " SSS5      nU R                  USSS5        [         R                  " SSS5      nU R                  USS	S
5        / SQnU R                  USSS5        U R                  USSSSS9  U R                  USSSSS9  g )Nrb   r   r8   r|  g|N?g7.s?r  r  g{CTp?g M<b*?r   gZL?g86J4?r  g+?r  r  r~  gHD?gr?r   r!  r  ru  s     rw   test_agree_with_r!TestKSOneSample.test_agree_with_ra  s    KKAq!a&9;NOKKR#a&9;OPNa&79JKa$57HwWa!24EGTrz   c                     [         R                  R                  SSSS9nU R                  USSSSS	9  U R                  US
SS5        U R                  USSS5        g )Nr  r  h:)r  r  r  r|  ghх?g7?asympr  r~  g^h?r  gv!ԉ}?g*z)?)ri   rG  r  r  ru  s     rw   test_known_examples#TestKSOneSample.test_known_examplesn  s`    JJNNs9NEa&9;O" 	 	$a!46JKa$9;NOrz   c           	         [        [        R                  " [        [        R                  SS5      5      5        [        [        SS9   [        SSS5        S S S 5        [        [        R                  " [        SSS5      5      5        [        R                  " / SQ5      n[        [        USS	5      R                  [        [        [        /S
9  g ! , (       d  f       N= f)Nr   Tzn is not integral: 1.5r   r;   rb   ))r  r   Tr   )r  皙?Tr   )r  r   Tr   )r  gTr   )r        ?Tr   )r  r  Fr   )r  r:   Tgb?)r  r:   FgiNq>)r        ?Tgv(?)r  rp  TgT	?)@  g\(\?Fr   )r         ?Fg(>)r   gQ?Fg@c?)r         ?FgX+ʳP?r  r2   )dtypes)r   r   r  r   rm   r   r   rf   r   checkintr  bool)rn   datasets     rw   test_ks1samp_allpaths%TestKSOneSample.test_ks1samp_allpathsv  s    D123:-EFCD! GQ-./** 
 4 	'9a066sE4>P6Q= GFs   C
Cksfunc*alternative, x6val, ref_location, ref_sign))r  r5   r5   r   )r~  r6   r6   rb   )r|  r5   r5   r   )r|  r6   r6   rb   c                     [         R                  " S5      S-   nX6S'   [        R                  " SS9R                  nU" XgUS9n[        UR                  SSS9  UR                  U:X  d   eUR                  U:X  d   eg )	Nr\   r:   r5   rV  r  r1  r2  r  )	r   r   ri   r  r  r   r*  statistic_locationstatistic_sign)	rn   r*  r  x6valref_locationref_signrp   r  r   s	            rw   test_location_sign"TestKSOneSample.test_location_sign  su     IIbMC!mm"%))Q5s7%%555!!X---rz   r   Nr  )r   r   r   r   r   r  r  r  r  r(  rP  r  r  ri   r  r  r2  r   r   rz   rw   r  r  O  s|    
 ')O-UP!RF [[Xenn'EF[[I78

.8 G
.rz   r  c                      \ rS rSrSr SS jrS rS rS rS r	S r
S	 rS
 r\R                  R                  S 5       r\R                  R                  S 5       rS rS r\R                  R(                  S 5       r\R                  R(                  S 5       r\R                  R                  S 5       rS r\R                  R                  S 5       r\R                  R5                  S/ S/4S// 4/ / 445      S 5       r\R                  R(                  S 5       rS r\R                  R5                  S\R>                  \R@                  /5      \R                  R5                  S/ SQ5      S 5       5       r!Sr"g) TestKSTwoSamplesi  z<Tests 2-samples with K-S various sizes, alternatives, modes.c                     [         R                  " XX6S9n[        R                  " XE/5      n[	        [        R                  " U5      U5        g )Nr  )ri   ks_2sampr   r   r   )	rn   r  r  r  r  r  r  r  r  s	            rw   r  TestKSTwoSamples._testOne  s7    ?88/?@!"((6"2H=rz   c                    U R                  S/S/SSS5        U R                  S/S/SSS5        U R                  S/S/SSS5        U R                  S/S/SSS5        U R                  S/S/SSS5        U R                  S/S/SSS5        g )	Nr   r   r|  r   r  r:   r~  r   )r  rh  s    rw   	testSmallTestKSTwoSamples.testSmall  s    qcA3UC8qcA3	5#6qcA3s3qcA3UC8qcA3	5#6qcA3s3rz   c                 h   [         R                  " SS/5      nUS-   nUS-
  n[         R                  " / SQ5      nU R                  X$SSS5        U R                  X$SSS5        U R                  X$S	SS5        U R                  X4SS
S5        U R                  X4SS
S5        U R                  X4S	SS5        g )Nr   rm  r  r  r|  rD  r  r2  r~  r5  rk  r4  r   r   r   r  rn   r  data1pdata1mr  s        rw   testTwoVsThreeTestKSTwoSamples.testTwoVsThree  s    #s$)f['3?fY=fVWc:f['3?fY=fVQ4rz   c                 h   [         R                  " SS/5      nUS-   nUS-
  n[         R                  " / SQ5      nU R                  X$SSS5        U R                  X$SSS	5        U R                  X$S
SS5        U R                  X4SSS5        U R                  X4SSS5        U R                  X4S
SS5        g )Nr   rm  r  r0  r|  r:   g?r  g?r~  rp  皙?r  rj  r  r   r=  r>  s        rw   testTwoVsFourTestKSTwoSamples.testTwoVsFour  s    #s$-.f['7CfY@fVWg>f['6BfY@fVQ4rz   c                 D   [         R                  " SSS5      nUS-   S-   nUS-   S-
  nU R                  XSSS5        U R                  XSSS	5        U R                  XS
SS5        U R                  XSSS5        U R                  XSSS5        U R                  XS
SS5        g )Nr   r  r1   r1  r|  r  g~z?r  gz;.B?r~  r   r   {Gz?gn2IU?r  )rn   x100	x100_2_p1	x100_2_m1s       rw   test100_100TestKSTwoSamples.test100_100  s    {{1c3'1HsN	1HsN	d{I?QRdy)=OPdvq#6d{IsCdy)=NOdvq#6rz   c                 t   [         R                  " SSS5      n[         R                  " SSS5      nUS-   S-   nUS-   S-
  nU R                  XSSS5        U R                  XS	SS
5        U R                  XSSS5        U R                  XSSS5        U R                  XS	SS5        U R                  XSSS5        g )Nr   r  rS  r  r1  r|  g?g@߿?r  g}n?r~  r   g:[?g]O);?gѫ);?r   r   r  )rn   rI  x110
x110_20_p1
x110_20_m1s        rw   test100_110TestKSTwoSamples.test100_110  s    {{1c3'{{1c3'BY_
BY_
d\CWXd	<AUVd15d\CWXd	<AUVdS9rz   c                 *   [         R                  " S/S-  S/S-  -   S/S-  -   S/S-  -   [        S9nUS-   n[         R                  " S/S-  S/S-  -   S/S-  -   S/S-  -   [        S9n[         R                  " S/S-  S/S-  -   S/S-  -   S	/S-  -   [        S9nU R                  XS
SS5        U R                  XSSS5        U R                  XSSS5        U R                  X4S
SS5        U R                  X4SSS5        U R                  X4SSS5        g )Nr1   r2   r3   r4   r5   rZ  r   r\   r6   r|  g      ?g^dH?r  gQl6y?r~  r   r   gVdEVdE?g(f^?g!?gii?g+ ϖ?)r   r   r%  r  )rn   x2233x3344x2356x3467s        rw   testRepeatedValues#TestKSTwoSamples.testRepeatedValues  s!   !qA37*aS1W4sQw>cJ	!qA37*aS2X5a?sK!rQC!G+qcBh6!q@LeK9KLeIv7JKeFFC8eK>PQeI{<NOeFJ8JKrz   c                    [         R                  " / SQ5      nU R                  XS-   SSS5        U R                  XS-   SSS5        U R                  XS-   SS	S5        U R                  XS
-   SSS5        U R                  XS
-   SSS5        U R                  XS
-   SS	S5        U R                  XS
-
  SSS5        U R                  XS
-
  SS	S5        U R                  XS
-
  SSS5        g )Nr  r   r|  rD  r   r  r  r~  r   r:   r=  )rn   r  s     rw   testEqualSizesTestKSTwoSamples.testEqualSizes  s    )e1Wk5#>e1Wi=e1WfeR8e3YUC@e3Y	5$?e3Yr:e3YUC@e3Y	5#>e3Yt<rz   c           
         Su  pSU-  U-  S-  S-  n[         R                  " SSU5      U-
  n[         R                  " SSU5      nU R                  XESSU-  U-  SSS	9  U R                  XESSU-  U-  SS
S	9  U R                  XESSU-  U-  SS
S	9  U R                  XESSU-  U-  SS
S	9  [        5        nSnUR	                  [
        U5        U R                  XESSU-  U-  SSS	9  U R                  XESSU-  U-  SSS	9  S S S 5        [        R                  " SS9 n[        R                  " S5        U R                  XESSU-  U-  SSS	9  [        U[
        S5        S S S 5        g ! , (       d  f       Nl= f! , (       d  f       g = f)N)r  iX  r   r1   r   r  r|  g     @@r  r  r  r  g2JE?r~  g     @@gsW\nc?)ks_2samp: Exact calculation unsuccessful.r  TrM  rN  
r   r!  r  r   r   r   rP  rQ  rR  r  	rn   n1n2deltarp   rq   r   r  r  s	            rw   testMiddlingBoth!TestKSTwoSamples.testMiddlingBoth  s    Br	!AKK3#e+KK3#aK"r)93! 	 	#aK"r)93" 	 	$aIv{R'79K" 	 	$aFEBJO5G" 	 	$ CAGJJ~w/MM!	6B;+;=O&  (MM!
R9K&  ( ! $$D1Q!!(+MM!
R9K&  (A~q1	 21 !  21   4AE%AE6%
E36
Fc           
         Su  pSU-  U-  S-  S-  n[         R                  " SSU5      U-
  n[         R                  " SSU5      nU R                  XESSU-  U-  SSS	9  U R                  XESSU-  U-  SS
S	9  U R                  XESSU-  U-  SSS	9  U R                  XESSU-  U-  SSS	9  [        5        nSnUR	                  [
        U5        U R                  XESSU-  U-  SSS	9  U R                  XESSU-  U-  SSS	9  S S S 5        [        R                  " SS9 n[        R                  " S5        U R                  XESSU-  U-  SSS	9  [        U[
        S5        S S S 5        g ! , (       d  f       Nl= f! , (       d  f       g = f)N)r  L  r   r1   r   r  r|  g     ȹ@r  r  r  r  gZ?r~  g     @@g@J?r_  r  TrM  rN  r`  ra  s	            rw   testMediumBothTestKSTwoSamples.testMediumBoth$  s    Br	!AKK3#e+KK3#aK"r)93" 	 	$aK"r)93! 	 	#aIv{R'79K" 	 	$aFFRK"$46H" 	 	$  CAGJJ~w/MM!	6B;+;=O&  (MM!b(8:L&  ( ! $$D1Q!!(+MM!b(8:L&  (A~q1	 21 !  21rg  c                 "   Su  pUS-  nSU-  U-  S-  S-  n[         R                  " SSU5      U-
  n[         R                  " SSU5      nU R                  XVSS	U-  S
5        U R                  XVSSU-  S5        U R                  XVSS	U-  S5        g )N)'  rS  r  r   r1   r   r  r  r|  g    `@g      <r  g     @g򼉷?r~  gimb:r  )rn   rb  rc  lcmrd  rp   rq   s          rw   	testLargeTestKSTwoSamples.testLargeA  s    gBr	!AKK3#e+KK3#aK38NOaIus{4GHaFGcM3IJrz   c           	         [         R                  R                  S5        [         R                  R                  SS9n[         R                  R                  SS9S-  nU R	                  XSSSS	S
9  U R	                  XSSSSS
9  g )N@ i  r  i  r;   r|  gC?      <r  r  r  r   r  rn  r  r  rp  s      rw   test_gh11184TestKSTwoSamples.test_gh11184L  s    
		vII$'II$'#-aK)<>T" 	 	$aK)<>T" 	 	$rz   c           	      T   [         R                  R                  S5        [         R                  R                  SS9n[         R                  R                  SS9S-  nU R	                  XSSSS	S
9  U R	                  XSSSSS
9  U R	                  XSSSS	S
9  U R	                  XSSSS	S
9  g )Nrr  rm  r  i'  r;   r|  g 	_r!?gAD5r  r  rs  r  r  gלN#y7r~  gvqw?rt  rp  s      rw   test_gh11184_bigger$TestKSTwoSamples.test_gh11184_biggerV  s     			vII%(II%(3.aK)<>T" 	 	$aK)<>T" 	 	$aI':<R" 	 	$aF$79O" 	 	$rz   c                    [         R                  R                  S5        [        SSS5       H  n[         R                  R	                  US9n[         R                  R	                  US-   SS9n[
        R                  " X#SS	9R                  n[
        R                  " X#S
S	9R                  n[        USU-  5        [        USU-  5        M     g )Nrr  r  i.  r  r\   r:   r  r  r  r  r  r2   )	r   r  rn  r  r  ri   r7  r)  r   )rn   rp   vals1vals2r  r  s         rw   test_gh12999TestKSTwoSamples.test_gh12999e  s    
		vtUD)AII$$1$.EII$$1r6$<ENN5g>EEENN5g>EEEeQY/eQY/ *rz   c           
      H   Su  pUS-  nSU-  U-  S-  S-  n[         R                  " SSU5      U-
  n[         R                  " SSU5      nU R                  XVSSU-  S	S
S9  U R                  XVSSU-  SSS9  U R                  XVSSU-  S	SS9  U R                  XVSSU-  S5        U R                  XVSSU-  S5        [        5        nSnUR	                  [
        U5        U R                  XVSSU-  SSS9  U R                  XVSSU-  SSS9  S S S 5        g ! , (       d  f       g = f)N)rm  i*  r  r   r1   r   r  r|  g     @gkHY?r  r  gLɔ.?r  r  r  g.LbG2?r~  r   gr?֎?r_  )r   r!  r  r   r   r   )	rn   rb  rc  rn  rd  rp   rq   r   r  s	            rw   testLargeBothTestKSTwoSamples.testLargeBothq  sL    gBr	!AKK3#e+KK3#aK6H" 	 	$aK6H" 	 	$aK6H! 	 	#aIus{4FGaFD3J0BC CAGJJ~w/MM!	53;8J&  (MM!s
4F&  ( !  s   AD
D!c                 R    Sn[         R                  " SS/S/5      n[        X!5        g )Nr  r   r1   r2   )ri   r7  r   rn   r,  r   s      rw   testNamedAttributes$TestKSTwoSamples.testNamedAttributes  s%    ,
nnaVaS)C,rz   c           	          SSK JnJn  U" SSSS5        U" SSSS5        [        R                  " SS9   [        [        USS	SS5        [        [        US
SSS5        S S S 5        g ! , (       d  f       g = f)Nr   )_count_paths_outside_method!_compute_outer_prob_inside_methodr   r  i  r   r~  ri  iK  r%  )scipy.stats._stats_pyr  r  r   r  r   FloatingPointError)rn   r  r  s      rw   test_some_code_paths%TestKSTwoSamples.test_some_code_paths  sk    	

 	*!Q15#D!Q5[[),.Ia,,.Ia, *))s   )A%%
A3r  r   c                 (   [         R                  " [        [        S9   [        R
                  " U6 n[        UR                  [        R                  5        [        UR                  [        R                  5        S S S 5        g ! , (       d  f       g = fr  )rP  rQ  r   r   ri   r7  r   r*  r   rm   r)  rn   r  r   s      rw   test_argument_checking'TestKSTwoSamples.test_argument_checking  sS     \\,4IJ..$'C/RVV, KJJ   AB
Bc                    [         R                  R                  S5        Sn[        R                  R                  USSS9nUS-   n[        R                  " X#SSS9  [        R                  " X#S	SS9  [        R                  " X#S
SS9  g)zEnsure gh-12218 is fixed.Na i    r   r   r  r  r  r  r~  r|  N)r   r  rn  ri   r  r  r7  )rn   rb  rvs1rvs2s       rw   test_gh12218TestKSTwoSamples.test_gh12218  sm    
 			x }}  bb :axtywGtvGDt{Irz   c                 >   [         R                  R                  SS9nUR                  SS9S-   nUR                  SS9nSn[        R                  " [
        US9   [        R                  " X#S	S
9n[        UR                  SSS9  S S S 5        g ! , (       d  f       g = f)Ni{frn  iq  r  r:   iq  z(ks_2samp: Exact calculation unsuccessfulr   r~  r  r   rX  r3  )
r   r  RandomStaterP  rQ  r   ri   r7  r   r)  )rn   r  r  r  r  r   s         rw   test_warnings_gh_14019'TestKSTwoSamples.test_warnings_gh_14019  s     ii###2


$s*


$<\\.8..6BCCJJ6 988s   +B
Br*  r+  ))r  皙@r  r   )r~  ffffff@r   rb   )r|  r  r  r   )r|  r  r   rb   c                    [         R                  " S[         R                  S9nUR                  5       nX6S'   [        R
                  " XgUS9nUR                  S:X  d   eUR                  U:X  d   eUR                  U:X  d   eg )Nr\   rZ  r5   r  r1  )	r   r   r   r=  ri   r7  r*  r-  r.  )	rn   r*  r  r/  r0  r1  rp   rq   r   s	            rw   r2  #TestKSTwoSamples.test_location_sign  st     IIb

+FFH!nnQ{;}}###%%555!!X---rz   r   N)r  )#r   r   r   r   r   r  r:  rA  rE  rL  rR  rY  r\  rP  r  r]  re  rj  ro  ru  r^  rx  r~  r  r  r  r  r  r  r  ri   r  r7  r2  r   r   rz   rw   r5  r5    s   F >4
55	7:
L
= [[2 26 [[2 28	K$ [[$ $ [[	0 	0 [[( (.- [[, ,  [[VrA3i1#rRH%EF- G- [[
J 
J
7 [[Xenn'EF[[I;<

.< G
.rz   r5  c            	         Su  pX * /X/4n[         R                  " SSS5      n[         R                  " SSS5      n[         R                  " [         R                  " SSS5      [         R                  " SSS5      /5      n[         R                  " [         R                  " SSS5      [         R                  " SSS5      /5      n[        R                  " X4SS9u  px[        Xx/X45        [        R                  " UR                  UR                  SS9u  px[        Xx/U5        [        R                  " XVSS9u  px[        Xx/U5        [        5        n	[         R                  " SSS	9   U	R                  [        S
5        [        R                  " SS5      u  pxS S S 5        S S S 5        [        [         R                  " U5      5        [        [         R                  " U5      5        Sn
[        R                  " X4SS9n[        X5        [         R                  " XUU/5      n[         R                  " XfU/5      n[        R                  " XSS9u  px[        [         R                  " U5      U 5        [        [         R                  " U5      U5        [!        UR"                  S5        [        R                  " [         R$                  " USS5      [         R$                  " USS5      SS9u  px[        [         R                  " U5      U 5        [        [         R                  " U5      U5        [!        UR"                  S5        ['        [(        [        R                  X4SS9  [        R                  " X4SSS9u  px[+        USUS-  -
  5        [+        Xp5        [        R                  " X4SSS9u  px[+        XS-  5        [+        Xp5        [         R,                  R/                  S5      n[        R0                  R3                  SSSUS9n[         R4                  US'   [        R0                  R3                  SSSUS9[        R0                  R3                  SSUS9-   n[         R4                  US'   [         R                  " SS9   [7        [        R                  " X5      [         R4                  [         R4                  45        S S S 5        [        [        R                  " UUSS 9S!5        ['        [(        [        R                  UUS"S 9  ['        [(        [        R                  UUS#S 9  [8        R:                  " [        S$S%9   [        R                  " / S&Q/ S'Q5      u  pxS S S 5        [!        [         R                  " U5      U4[         R<                  S45        [         R                  " SS9   [!        [        R                  " / S&Q/ S&Q5      [         R4                  [         R4                  45        [         R                  " S[         R4                  /S(S//5      n[!        [        R                  " U[         R>                  " S)5      5      S[         R4                  /S[         R4                  /45        S S S 5        [         R@                  " S*5      n['        [(        [        R                  URC                  S+5      URC                  S,5      5        S- n[         RD                  " U5      n[         R4                  US S 2S.S/24'   [         R4                  US S 2S0S124'   [8        R:                  " [F        [H        S%9   [        R                  " XVSSS 9u  pS S S 5        [8        R:                  " [F        [H        S%9   [        R                  " XVSSSS29u  pxS S S 5        [+        XpS3S49  [         R                  " SS9   [+        UU" XS5      S3S49  S S S 5        [8        R:                  " [F        [H        S%9   [        R                  " XVSSSS29u  pxS S S 5        [+        XpS3S49  [         R                  " SS9   [+        UU" XS5      S3S49  S S S 5        g ! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN&= f! , (       d  f       GN%= f! , (       d  f       GNZ= f! , (       d  f       GN-= f! , (       d  f       GN= f! , (       d  f       N= f! , (       d  f       g = f)5N)gu?gȵI?r   r  r  gKX@r   rV   r}  r  r  r   r1  r  rF  r1   r0  r  r  r~  r  r  r  r4   r\     r  r  r  )r  r  r  r~  r   r   )ghm#1?gry̧?r   r   r  r   rq  r  rb   r1  r~  )r7   r2   r1   r2   r3   c                 L    U S:  a  US:X  d  U S:  a  US:X  a  US-  $ SUS-  -
  $ Nr   r~  r  r1   r   r   r  rT  alts      rw   converttest_ttest_rel.<locals>.convert.  3    EcVmQ3)3Cq5LAE{rz   r  r  r  r  rQ  rX  r  )%r   r!  r   ri   	ttest_relr   r  r   r  r   r   r   r  r   r2  absr   r  r3  r   r   r   r  r  rG  r  rm   r	   rP  rQ  r  rH  r   rk   	vectorizer   r   )trr4  tprr  r  rvs1_2Drvs2_2Dr  rT  r   r,  r   rvs1_3Drvs2_3Dr  rp   rq   ananr  	converters                       rw   test_ttest_relr    sK   4EBs8RG
C;;qS!D;;tF3'DhhAc#.D0LMNGhhD4bkk!C6LMNG
//$1
-CAqeRG,
//'))WYYQ
7CAqeC(
//'
3CAqeC( 
	KK:

>#FGr2& ; 
 BHHQKBHHQK )J
//$1
-C( ii12Gii12G
//'
3CAbffQi,bffQi,&!??2;;w15;;w15 !#DA bffQi,bffQi,&! *eootwO??4A6BDAAq2a4x A??4A9EDAA!tA ))


)C

1BSsCAVVAcF	ARc	D	c#	>
?AVVAcF	X	&5??102662662BC 
' eooavFGI*eooq!H*eooq!I 
n,E	Fy)4 
G"&&)Q"&&!-	X	&U__Y	:RVVRVV<LM xx!RVVr1g./U__T288F+;<"&&kArvv;/	1 
' 			"A*eooqyy/@))I&( W%IGAr"uHGAr"uH	(0A	B1H 
C 
(0A	Bw*0fF 
C A&	X	&9RV45A 
' 
(0A	Bw*0iI 
C A&	X	&9RY7eD 
'	&} ;: 
	\ 
'	& 
G	F 
'	&. 
C	B 
C	B 
'	& 
C	B 
'	&s   a&0`?a:?a#8a5$Cb-b+b++b=#c#c ?
a		a
a #
a25
b
b
b(+
b:=
c
c 
c.c                  j   [         R                  SSS/n / SQn[        R                  " XSS9n[        R                  " XSS9n[	        UR
                  UR
                  * SS9  [	        UR                  UR                  SS9  [        R                  " US	S  U S	S  5      n[	        X4SS9  [	        US
SS9  g )Nrm  r1  r   r   rm  r   rm  r   r   r2  r3  r   )rQ  grh|?-C6?)r   rm   ri   r  r   r*  r)  rp   rq   ru  rv  r3s        rw   test_ttest_rel_nan_2nd_argr  I  s    	c3AA	&	1B	&	1BBLL2<<-e<BIIryyu5 
12!"	&BB' B40rz   c                  J   [         R                  " [        [        S9   [        R
                  " / / 5      n S S S 5        [        W [        R                  R                  5      (       d   e[        U [        R                  [        R                  45        g ! , (       d  f       Nd= fr  )rP  rQ  r   r   ri   r  r#  	_stats_pyTtestResultr   r   rm   )r  s    rw   #test_ttest_rel_empty_1d_returns_nanr  ^  sh     
(0E	FR( 
Gfeoo99::::"&&"&&)* 
G	Fs   B
B"zb, expected_shape)r   r4   r   r  r   r   r   )r2   r   c                    [         R                  " S5      n[         R                  R                  5        nUR	                  [
        [        5        [        R                  " X SS9nS S S 5        [        W[        R                  R                  5      (       d   e[         R                  " U[         R                  S9n[        UR                  U5        [        UR                   U5        g ! , (       d  f       N= fN)r2   r   r   rb   rV   r  )r   rC  r  r   r   r   r   ri   r  r#  r  r  r   rm   r   r*  r)  )rE  expected_shaper9  r   r  expected_values         rw   test_ttest_rel_axis_size_zeror  g  s     	A		%	%	'3

%'<=B/ 
( feoo99::::WW^?N!!>2/ 
(	's   0C((
C6c                  \   [         R                  " S5      n [         R                  " S5      n[        R                  " XSS9n[	        U[        R
                  R                  5      (       d   e[        UR                  R                  S5        [        UR                  R                  S5        g N)r   r7   r   r4   r7   r   r   rV   r4   r   )r   rC  ri   r  r#  r  r  r   r*  r  r)  )r9  rE  r  s      rw    test_ttest_rel_nonaxis_size_zeror  y  sw    
 	A
A__Q*Ffeoo99::::!!''0$$f-rz   r  r=  c                 r   [         R                  R                  S5      nSnUR                  USSS9nUR                  USSS9nSS/S[         R                  /[         R                  * S	/S
.n[
        R                  " X4U S9nUR                  SS9n[        XuU    5        [        UR                  US-
  5        g )Nl   C67l:  r\   r;   r1   r  gZ?Ygi{a?g8 gC?r  r  r  r  r   )r   r  r  r  r  ri   r  ro  r   r   r  )r  r  r  rp   rq   r  r   r  s           rw   test_ttest_rel_ci_1dr    s     ))

 3
4C
A

s!
,A

q
*A ,->?)2662VVG013C //!K
8C		 	 $	 	7BBK()1rz   ztest_fun, argsr\   c                     U " U6 nSn[         R                  " [        US9   UR                  SS9  S S S 5        g ! , (       d  f       g = f)Nr!  r   r\   r  )rP  r   r   ro  )test_funr0  r   r  s       rw   test_ttest_ci_ivr    s=    
 D/CDG	z	14 
2	1	1s	   :
Ar  c                V   ^ Tc  [        X5      OTmSU4S jjnU" X5      U" X5      -   $ )Nc                    > TR                  U 5      n TR                  XS9nTR                  XSS9nU R                  U   nX#U4$ )NrV   r   r  )rf   rl   r   r  )rp   rW   mur   nobsro   s        rw   _stats_desc_stats.<locals>._stats  sI    JJqMWWQW"ffQaf0wwt}}rz   r-  )r)   )r  r  rW   ro   r  s      ` rw   _desc_statsr    s/    $&J	 BB "fR...rz   c                 
   U R                  S5      nU R                  S5      nU R                  X* /5      nU R                  X"/5      nU R                  SSS5      nU R                  SSS5      nU R                  XV/5      nU R                  Xe/5      n[        R                  " XVSS9n	U	u  p[        X5        [        X5        [        R                  " [        XV5      6 n	U	u  p[        X5        [        X5        [        R                  " UR                  UR                  SS9n	[        U	R                  U5        [        U	R                  U5        [        R                  " [        UR                  UR                  5      6 n	[        U	R                  U5        [        U	R                  U5        [        R                  " XxSS9n	[        U	R                  U5        [        U	R                  U5        [        R                  " [        XxSS96 n	[        U	R                  U5        [        U	R                  U5        S	n[        R                  " [        US
9   [        R                  " XVSS9  S S S 5        [        UR                  UR                  5      n[        R                  " [        US
9   [        R                  " USS06  S S S 5        [        R                  " XVSS9u  p[        USUS-  -
  5        [        X5        [        R                  " XVSS9u  p[        XS-  5        [        X5        [        R                  " UR                  UR                  SSS9n[        UR                  UR                  5      n[        R                  " USS06n[        UR                  UR                  5        [        UR                  UR                  5        [        R                  " UR                  UR                  SSS9n[        UR                  UR                  5      n[        R                  " USS06n[        UR                  UR                  5        [        UR                  UR                  5        U R                  U R                  5      nU R                  U R!                  UR"                  S   5      S:H  UU5      n[        R                  " XVSS9n	[%        U	R                  U5        [%        U	R                  U5        [        R                  " [        XV5      6 n	[%        U	R                  U5        [%        U	R                  U5        g ! , (       d  f       GN= f! , (       d  f       GN= f)N	ru?g8Mѱ?r4   i   r  r   r   rV   r  r   r  r  r  r~  r1   r  r  )rf   r!  r  ri   	ttest_indr/   ttest_ind_from_statsr  r  r*  r)  rP  r   r   rm   rP  r   r  r0   )ro   r  r4  tr_2Dpr_2Dr  r  r  r  r   r  rT  r  r0  r  r  NaNs                    rw   test_ttest_indr    s    
&	'B	'	(BJJCy!EJJx E;;q#s#D;;q#s#Dhh|$Ghh|$G
//$1
-CDAAA

$
$k$&=
>CDAAA
//'))WYYQ
7CCMM5)CJJ&

$
$k'))WYY&G
HCCMM5)CJJ&
//'
3CCMM5)CJJ&

$
$k'&K
LCCMM5)CJJ& IG	z	1': 
2 wyy')),D	z	1""D@@ 
2 ??46:DAAqBqDz"A??49=DAA!tA ??799giiaVLDwyy')),D%%t@@DDNNDNN3DKK-??799giiaVLDwyy')),D%%t@@DDNNDNN3DKK- **RVV
C88BIIdjjm,13=D
//$1
-CCMM3'CJJ$

$
$k$&=
>CCMM3'CJJ$M 
2	1 
2	1s   U $U 
U
U!c            	      "   [         R                  " SSS5      n [         R                  " SSS5      n[         R                  " X/5      n[         R                  " X/5      n[         R                  " X"U/5      n[         R                  " X3U/5      n[         R                  R                  S5      n[        R                  R                  SSSUS9n[         R                  US	'   [        R                  R                  SSS	US9n[         R                  " S
S9   [        [        R                  " Xx5      [         R                  [         R                  45        S S S 5        [        [        R                  " XxSS9S5        [        [        [        R                  XxSS9  [        [        [        R                  XxSS9  [         R"                  " [$        SS9   [        R                  " / SQ/ SQ5      u  pS S S 5        ['        [         R(                  " W	5      W
4[         R*                  S45        [         R                  " S
S9   ['        [        R                  " / SQ/ SQ5      [         R                  [         R                  45        [         R                  " S[         R                  /SS//5      n['        [        R                  " U[         R,                  " S5      5      S[         R                  /S[         R                  /45        S S S 5        [         R                  US S 2S S 2SS24'   [         R                  US S 2S S 2SS24'   S n[         R.                  " U5      n[        R                  " XESSS9u  p[        R                  " XESSSS9u  p[1        XSS 9  [1        X" XS5      SS 9  [        R                  " XESSS!S9u  p[1        XSS 9  [1        X" XS!5      SS 9  g ! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f)"Nr4   r  r  r   r  r\   r  r  r  r}  r~  r   r   )guͷ?g*,?r   r   r  r   rq  r  r   rb   r1  r  r5   r^   c                 L    U S:  a  US:X  d  U S:  a  US:X  a  US-  $ SUS-  -
  $ r  r   r  s      rw   r  *test_ttest_ind_nan_policy.<locals>.convert5  r  rz   r  r~  )rW   r   r  rX  r  r  )r   r!  r   r2  r  r  ri   rG  r  rm   r  r	   r  r   r   r   rP  rQ  r   r   r  r  rH  r  r   )r  r  r  r  r  r  r  rp   rq   r  rT  r  r  r  r  r4  s                   rw   test_ttest_ind_nan_policyr    s   ;;q#s#D;;q#s#Dhh|$Ghh|$Gii734Gii734G ))


)C

1BSsCAVVAcF

1BSsCA	X	&5??102662662BC 
' eooavFHJ*eooqH*eooqI 
n,E	Fy)4 
G"&&)Q"&&!-	X	&U__Y	:RVVRVV<LM xx!RVVr1g./U__T288F+;<"&&kArvv;/	1 
' 66GAq"R%K&&GAq!B$J W%I__WA&IFB??7!'-/DAA&Ay0u=??7!'02DAA&Ay3%@S 
'	& 
G	F 
'	&s%   ?OO-<CO?
O*-
O<?
Pc                  z   [        5        n [        R                  " SS9   U R                  [        S5        [
        R                  " SS5      u  pS S S 5        S S S 5        [        R                  " W5      (       d   e[        R                  " W5      (       d   eg ! , (       d  f       NQ= f! , (       d  f       NZ= f)Nr}  r~  r  r   r1  )r   r   r  r   r   ri   r  r  )r   r  rT  s      rw   test_ttest_ind_scalarr  H  sv    		R[[%B

>#FGr2& &C	 88A;;;88A;;;	 &C%B		s"   B,0BB,
B)	%B,,
B:z&ignore:Arguments...:DeprecationWarningc                      \ rS rSrSr\R                  R                  S5        \R                  " \R                  " S\-  S-  5      \R                  R                  S\-  S-  5      45      r
\R                  " \R                  " \S-  5      S-   \R                  R                  \S-  5      45      r\R                  " S5      r\R                  " S5      S-   rSS	/rSS/r\R                  R                  S5        \R"                  R%                  S
SSS9R'                  SS
5      R(                  r\R"                  R%                  SSSS9rSS/rSS/r/ SQr\
\SS0\4\
R(                  \R(                  SS0\4\
SSS24   \SSS24   SS0\S   4\
SSS24   R5                  5       \SSS24   R5                  5       SS0\S   4\
\SSS.\4\
\\R                  R7                  S5      SS.\4\\SS0S4\\SSS.\4\\0 S4\
\\R                  R9                  S5      SS.\4/
r\R>                  RA                  S\5      S 5       r!S r"S r#S r$S r%\R>                  RM                  5       S  5       r'S! r(S" r)S# r*\R>                  RA                  S$/ S%Q5      \R>                  RA                  S&S'S(/5      S) 5       5       r+\R>                  RA                  S$/ S%Q5      \R>                  RA                  S&S'S(/5      S* 5       5       r,S+ r-\.\R>                  R_                  SS,S-9\R>                  Ra                  S.5      S/ 5       5       5       r1S0r2g)1Test_ttest_ind_permutationsiQ  r  r   r2   r3   r  r\   r   r1   r4   r  r  r7   g'^P?gCq?g$R?)g=B?g?goŜ?gp?g'^?rW   N)r  rW   	equal_varTrb   )rW   r  rD  za,b,update,p_dc                     S SS.nS SSSS.nUR                  U5        UR                  U5        [        R                  " X40 UD6u  px[        R                  " X40 UD6u  p[        XyS5        [        X5        g )NFrW   r  r  r   )rW   r  permutationsr  r4   )updateri   r  r   )rn   r9  rE  r  p_d	options_a	options_pstat_ar  stat_pr)  s              rw   test_ttest_ind_permutations7Test_ttest_ind_permutations.test_ttest_ind_permutations{  su    !6	!%)1>	  OOA6I6	;;!&!4!&.rz   c                 D   [         R                  R                  S5        Sn[         R                  R                  SUS5      n[         R                  R                  SUS5      nSSS.nUR	                  SS9  [
        R                  " X#40 UD6n[
        R                  " X240 UD6nUR	                  S	S9  [
        R                  " X#40 UD6n[
        R                  " X240 UD6nUR	                  S
S9  [
        R                  " X#40 UD6n	[
        R                  " X240 UD6n
[        UR                  UR                  5        [        UR                  U	R                  5        [        UR                  UR                  * 5        [        UR                  UR                  * 5        [        U	R                  U
R                  * 5        [        U	R                  U
R                  5        [        UR                  UR                  5        [        UR                  UR                  5        UR                  S:*  n[        UR                  U   UR                  U   -   U	R                  U   5        [        UR                  U)    UR                  U)    -   U	R                  U)    5        g )Nr   r2   r1   r   r  )rW   r  r  r  r~  r|  r:   
r   r  rn  r|  r  ri   r  r   r*  r)  )rn   Nr9  rE  r  res_g_abres_g_bares_l_abres_l_bares_2_abres_2_bar  s               rw    test_ttest_ind_exact_alternative<Test_ttest_ind_permutations.test_ttest_ind_exact_alternative  s   
		qIINN1a#IINN1a#5	Y/??1595??1595V,??1595??1595[1??1595??1595 	X''););<X''););< 	X''(*<*<)<=X''(*<*<)<=X''(*<*<)<= 	X__hoo6 	X__hoo6X__hoo6#%X__T*X__T-BB__T*	,X__dU+hoote.DD__dU+	-rz   c                 0   [         R                  R                  S5        Sn[         R                  R                  U5      n[         R                  R                  U5      n[        R
                  " X#5      n[        R
                  " X#SS9n[        R
                  " X#SS9n[        R
                  " X#[         R                  S9nUR                  UR                  :w  d   eUR                  UR                  :X  d   eUR                  UR                  :X  d   eg )Nr   r2   r  r  )r   r  rn  r|  ri   r  r  r)  )rn   r  r9  rE  r  r  r  r  s           rw   test_ttest_ind_exact_selection:Test_ttest_ind_permutations.test_ttest_ind_exact_selection  s    
		qIINN1IINN1q$q$7q!4q"&&9{{dkk))){{dkk))){{dkk)))rz   c                    [         R                  R                  S5        [         R                  R                  S5      n[         R                  R                  S5      n[         R                  " X45      n[        U5      [        U5      pTSn[        X6US5      u  n  n[        [        U5      5      n	U	[        XE-   U5      :X  d   e[        U5      U	:X  d   eg )Nr   r2   r3   rZ  T)	r   r  rn  r|  re  r  r   setr   )
rn   r9  rE  r  nanbr  t_statr  n_uniques
             rw   !test_ttest_ind_exact_distribution=Test_ttest_ind_permutations.test_ttest_ind_exact_distribution  s     			qIINN1IINN1~~qf%QQB24r3791 s6{#5"----6{h&&&rz   c                 H   [         R                  R                  S5        Sn[         R                  R                  SSU5      n[         R                  R                  SU5      nSSSS.nUR	                  SS	9  [
        R                  " X#40 UD6n[
        R                  " X240 UD6nUR	                  S
S	9  [
        R                  " X#40 UD6n[
        R                  " X240 UD6n[        UR                  UR                  5        [        UR                  UR                  * 5        [        UR                  UR                  * 5        [        UR                  UR                  -   SSUS   S-   -  -   5        [        UR                  UR                  -   SSUS   S-   -  -   5        g )Nr   r   r1   r2   rb   r  )rW   r  r  r  r  r~  r   r  r  )	rn   r  r9  rE  r  r  r  r  r  s	            rw   #test_ttest_ind_randperm_alternative?Test_ttest_ind_permutations.test_ttest_ind_randperm_alternative  se   
		qIINN1a#IINN1a qI	Y/??1595??1595V,??1595??1595 	X''););< 	X''(*<*<)<=X''(*<*<)<= 	X__x6In59::	<X__x6In59::	<rz   c                    [         R                  R                  S5        Sn[         R                  R                  US5      n[         R                  R                  US5      nSSS.nUR	                  SS9  [
        R                  " X#40 UD6nUR	                  SS9  [
        R                  " X#40 UD6nUR	                  S	S9  [
        R                  " X#40 UD6n[        UR                  UR                  -   S
S
US   S
-   -  -   5        UR                  S:*  n[        SUR                  U   -  UR                  U   SS9  [        SS
UR                  U)    -
  -  UR                  U)    SS9  [        SUR                  U)    -  UR                  U)    SS9  [        SS
UR                  U   -
  -  UR                  U   SS9  g )Nr   r   r3   r  r  r  r  r  r~  r|  r   r  r:   r1   rH  r3  )
r   r  rn  r|  r  ri   r  r   r)  r   )	rn   r  r9  rE  r  r  r  r  r  s	            rw   $test_ttest_ind_randperm_alternative2@Test_ttest_ind_permutations.test_ttest_ind_randperm_alternative2  s   
		qIINN1a IINN1a %*A>	Y/??1595V,??1595[1??1595 	X__x6In59::	<
 #%HOOD11 -D	:Qxu556 .T	;HOOTE22 .T	;Qxt445 -D	:rz   c                    [         R                  R                  S5        Sn[         R                  R                  US5      n[         R                  R                  US5      n[         R                  US'   [         R                  US'   [         R                  US'   [         R                  US'   SSS.nUR                  S	S
9  [        [        SS9   [        R                  " X#40 UD6nS S S 5        [        5        nUR                  [        S5        UR                  SS
9  [        R                  " X#40 UD6n[         R                  " U5      R                  SS9[         R                  " U5      R                  SS9-  n[        R                  " US S 2U) 4   US S 2U) 4   40 UD6n[        UR                   U   [         R                  5        [        UR"                  U   [         R                  5        [%        UR                   U)    UR                   5        [%        UR"                  U)    UR"                  5        [        R                  " UR'                  5       UR'                  5       40 UD6n[         R                  " UR                   5      (       d   e[         R                  " UR"                  5      (       d   e S S S 5        g ! , (       d  f       GN= f! , (       d  f       g = f)Nr   r   r4   r4   r   )r7   r1   )r8   r2   r  r	  r   r   r   r   r   r  rV   )r   r  rn  r|  rm   r  r   r   ri   r  r   r   r   r  r  r   r)  r*  r   r  )	rn   r  r9  rE  r  r   r   r  r  s	            rw   $test_ttest_ind_permutation_nanpolicy@Test_ttest_ind_permutations.test_ttest_ind_permutation_nanpolicy  s   
		qIINN1a IINN1a &&$&&$&&$&&$%)1=	 	G,:-LM//!4)4C N  CJJ~'784//!4)4C88A;???*RXXa[__!_-DDD??1QX;!dU(IyIDD)2662t,bff5CJJu-t{{;CMM4%0$..A //!'')QWWYD)DC88CJJ''''88CMM****# ! 	 NM ! s   K:GK
K
K(c           	         [        [        SS9   [        R                  " U R                  U R
                  SS9  S S S 5        [        [        SS9   [        R                  " U R                  U R
                  SS9  S S S 5        [        [        SS9   [        R                  " U R                  U R                  SSSS	9  S S S 5        g ! , (       d  f       N= f! , (       d  f       Nc= f! , (       d  f       g = f)
NzPermutations must ber   rc   r	  r;   z'hello' cannot be usedr   hello)r  r  rW   )r   r   ri   r  r  b2r9  rE  rh  s    rw   'test_ttest_ind_permutation_check_inputsCTest_ttest_ind_permutations.test_ttest_ind_permutation_check_inputs6  s    :-CDOODGGTWW2> E:-CDOODGGTWW3? E:-EFOODFFDFF)0q: GF	 EDDDFFs#   +C+C-C)
C
C&)
C7c                     Sn[         R                  R                  US5      n[         R                  R                  US5      n[        R                  " X#SS9R
                  n[        SU;  5        SU;  d   eg )Nr\   r  r   r	  r   )r   r  r|  ri   r  r)  print)rn   r  r9  rE  p_valuess        rw   )test_ttest_ind_permutation_check_p_valuesETest_ttest_ind_permutations.test_ttest_ind_permutation_check_p_values?  s`    IINN1b!IINN1b!??1a8??c!"("""rz   r  r  r  )r^   )r1   r^   c                    [         R                  R                  S5      nUR                  US9nUR                  SS9n[        SS9n[         R                  R                  S5      n[        R
                  " SSU0UD6n[        R                  " XESXS	9nS
 n	[         R                  R                  S5      n[        R                  " XE4U	4SUUS.UD6n
[        UR                  U
R                  5        [        UR                  U
R                  5        [        R                  " XESUS9n
[        UR                  U
R                  5        [        UR                  U
R                  SS9  g )N   Nvf_aB r  r_     rT     N\Sju	 r  rb   rW   r  r  c                 @    [         R                  " XUS9R                  $ NrV   ri   r  r*  rp   rq   rW   s      rw   r*  FTest_ttest_ind_permutations.test_permutation_method.<locals>.statisticW      %//!T*J*T*T#Trz   )rW   r  r  r  r  r  r   )r   r  r  r  ri   r  r  permutation_testr   r*  r)  r   )rn   r  r  r  rp   rq   r1  r  r   r*  r  s              rw   test_permutation_method3Test_ttest_ind_permutations.test_permutation_methodH  s*    ii##$45JJEJ"JJBJ#& ii##O4((;S;F;ooaT 	Uyy$$_5$$aVY HRS1<H@FH 	S]]CMM2SZZ, ooaES]]CMM2

CJJT:rz   c                    [         R                  R                  S5      nUR                  US9nUR                  SS9n[        SS9nS n[         R                  R                  S5      nUR                  UR                  /n[
        R                  " XE44XSUS	.UD6n	[         R                  R                  S5      nUR                  UR                  /n[
        R                  " SS
U0UD6n
[
        R                  " XESXS9n[        UR                  U	R                  5        [        UR                  U	R                  5        [
        R                  " SSS0UD6n
[
        R                  " XESXS9n[        UR                  U	R                  5        [        UR                  U	R                  5        [
        R                  " XESUS9n	[        UR                  U	R                  5        [        UR                  U	R                  SS9  g )Nr#	  r  r_   r$	  r%	  c                 @    [         R                  " XUS9R                  $ r)	  r*	  r+	  s      rw   r*  FTest_ttest_ind_permutations.test_monte_carlo_method.<locals>.statisticn  r-	  rz   r&	  rb   )r  r*  rW   r  r  r'	  r  r  r  r  r   )r   r  r  r  r  ri   monte_carlo_testr  r  r   r*  r)  r   )rn   r  r  r  rp   rq   r1  r*  r  r  r  r   s               rw   test_monte_carlo_method3Test_ttest_ind_permutations.test_monte_carlo_methodd  s    ii##$45JJEJ"JJBJ#& 	Uii##O4""C$7$78$$aV HPR1<H@FH ii##O4""C$7$78'':C:6:ooaTS]]CMM2SZZ, ''FOFvFooaTS]]CMM2SZZ, ooaES]]CMM2

CJJT:rz   c                     Sn[         R                  " [        US9   [        R                  " / SQ/ SQSS9  S S S 5        g ! , (       d  f       g = f)NzC`method` must be an instance of `PermutationMethod`, an instance...r   r  r   	migratoryr  )rP  r   r   ri   r  r&  s     rw    test_resampling_input_validation<Test_ttest_ind_permutations.test_resampling_input_validation  s1    W]]:W5OOIyE 655s   A  
Ar  r  rH   c                    UR                  U R                  5      UR                  U R                  5      p2Sn[        U5      (       a  [        R
                  " X#SS9  O7[        R                  " [        US9   [        R
                  " X#SS9  S S S 5        Sn[        R                  R                  S5      n[        R                  " US9n[        U5      (       a  [        R
                  " X#US9  g [        R                  " [        US9   [        R
                  " X#US9  S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)	Nz;Use of `permutations` is compatible only with NumPy arrays.r\   r	  r   z?Use of resampling methods is compatible only with NumPy arrays.l   /gGy r  r  )rf   r  r	  r+   ri   r  rP  r   r  r   r  r  r  )rn   ro   r  r	  r  r  r  s          rw   %test_permutation_not_implement_for_xpATest_ttest_ind_permutations.test_permutation_not_implement_for_xp  s    
 DGG$bjj&9BOB<<OOB42'BR8 C Tii##$45((S1B<<OOB622'Bv6 CB CB CBs   7D(	D9(
D69
Er   )3r   r   r   r   r  r   r  rn  rC  r   r9  rE  r  r	  r  b3ri   rG  r  rk   r  r  r  r  p_d_genp_d_bigrh   r  r  paramsrP  r  r  r  r  r	  r	  r	  r]  r	  r	  r	  r 	  r/	  r5	  r9	  r'   rH   r  r<	  r   r   rz   rw   r  r  Q  s   
A IINN1
		299QqS!V$bii&6&6qsAv&>?@A
		299QT?S("))*:*:1a4*@ABA 
2B	2	B QB
QB IINN1::>>ar"  $$+GCOAA 	::>>ar>4D<
 C~&G+G 
A{C 	
accFA;$	
1a4!AqD'FD>3q62	
1a4	1QT7>>+fd^SVD	
A1-s3	
A		 5 5a 8!DcJ	R+t$f-	tb!4g>	RS	
A		 5 5a 8!DgN
F [[-v6
/ 7
/(-T*'&<: [[: :B"+H:# [[],LM[[Wug&67; 8 N;4 [[],LM[[Wug&67; 8 N;BF
 [[!!4)D " F[[/07 1F 7rz   r  c                      \ rS rSr\R
                  R                  5       \R
                  R                  SSSS.SS00 // SQS	9\R
                  R                  S
SS/S
S/S	9S 5       5       5       r\R
                  R                  SSSS.SS00 // SQS	9\R
                  R                  SSS/5      S 5       5       r	Sr
g)Test_ttest_ind_commoni  kwdsr  r   r	  trimr  )r  rE	  basic)idsr  TFunequal_varc           	      Z   [         R                  R                  S5        [         R                  R                  SSSSSS5      n[         R                  R                  SSSSS5      n[        R
                  " X44S	S
0UD6nSu  pgnX6S S 2US S 2SS S 24   n	US S 2SS S 2US S 24   n
[        R
                  " X4S	S0UD6n[        UR                  US S 2XxS S 24   UR                  5        [        UR                  US S 2XxS S 24   UR                  5        [         R                  " [         R                  " US5      S
S5      n[         R                  " [         R                  " US5      S
S5      nUR                  S S n[         R                  " U5      n[         R                  " U5      n[        S U 5       6  HE  nUU   nUU   n[        R
                  " UU4S	S0UD6nUR                  UU'   UR                  UU'   MG     [        XR                  5        [        UUR                  5        g )Nr   r4   r3   r6   r   r5   r7   r1   rW   rc   )r1   r2   r   rQ  r   r   r   r   r1   r   rb   r4   r   r3   r   r   r   c              3   8   #    U  H  n[        U5      v   M     g 7fr  r  .0r  s     rw   	<genexpr>=Test_ttest_ind_common.test_ttest_many_dims.<locals>.<genexpr>  s      95aq5   )r   r  rn  r|  ri   r  r   r*  r)  r3  tiler  rH  r   r   )rn   rD	  r  r9  rE  r   r  r  r~  r  r	  r  rp   rq   r  
statisticspvaluesindicesxiyir  s                        rw   test_ttest_many_dims*Test_ttest_ind_common.test_ttest_many_dims  s    			qIINN1aAq!,IINN1aAq)ooa44t4 a!Q1a q!Q1}r7B7$7S]]1aq=1^^	%SZZ1aA.[[	" KK#56B?KK#56B?XXe_
((5/ 95 9:G7B7B??2r;;d;D"&..Jw#{{GG ; 	
MM2,rz   )rE	  r  rF	  rW   rb   c                 L   [         R                  R                  SSS9R                  S5      n[         R                  R                  SSS9R                  S5      n[         R                  US   S   S'   [         R                  US   S   S'   [         R
                  " [         R                  " X4-   US	95      n[        5        n[         R                  " S
S9   UR                  [        S5        UR                  [        S5        [        R                  " X44SU0UD6nS S S 5        S S S 5        [         R
                  " WR                  5      n[        X5        [         R
                  " UR                  5      n	[        X5        g ! , (       d  f       Nm= f! , (       d  f       Nv= f)Nr\   )r4   r2   r\   r  r  r   r1   r2   r5   rV   r}  r~  z'invalid value encountered in less_equalr  rW   )r   r  randintr  rm   r  rM  r   r  r   r   ri   r  r)  r	   r*  )
rn   rD	  rW   r9  rE  r  r   r   p_nansstatistic_nanss
             rw   test_nans_on_axis'Test_ttest_ind_common.test_nans_on_axis  s1    IIbz299'BIIbz299'BVV!Q
VV!Q
 88BFF15t45  CX)FJJ~@BJJ~'@A//!:T:T:C	 *G 
 #**%6,#--0>4 *G)F  s%   FAFF
F	F
F#r   N)r   r   r   r   rP  r  r^  r  rY	  r_	  r   r   rz   rw   rC	  rC	    s     [[[[VsA&N'-rlB&8!B  D [[[4-"-}!=  ?!-?D !-F [[VsA&N'-rlB&8!B  D [[Vb!W-5 .D5rz   rC	  c            	          \ rS rSr/ SQ/ SQSSS// SQ/ SQSS	S// SQ/ SQS
SS// SQ/ SQSSS// SQ/ SQSSS//r\R                  R                  S\5      S 5       rS r	S r
\R                  R                  SS5      S 5       rS r\\R                  R                  SSS9\R                  R                  S 5      S! 5       5       5       r\R                  R                  S"/ S#Q5      S$ 5       rS%rg&)'Test_ttest_trimi  r  r  r  g@g9(?ger  )r7  g33333`@r^   g33333^@g(\P@r  gfffffڇ@gBM)u?g]@gyd?g	s5v@g{Gz?r  r  r  r1  ffffff?r1  r  r  r4  re	  re	  r@   g@r  r=   r:   r  g333333@r  r  g@r  gn4aƂg?^)g,
gm?giI@gE|x!gvwQ?glfPg_)gXG~?g=n@g8$mg({g]:m?gYv gb?gb	gSTß}g9yg.Ͽv?g޺i?g	'X@)g>_\?g hO?gau?@g׌g+?g:؜^gz54g7f?gDO%@g#xG@g\F?g4E?gnfg>P"ۿguX@gvR?g%?g2Ydzgo?gih?gn?g!nu?gJ+bza,b,pr,tr,trimc                 \    [         R                  " XUSS9u  pg[        XdSS9  [        XsSS9  g)a8  
Using PairedData's yuen.t.test method. Something to note is that there
are at least 3 R packages that come with a trimmed t-test method, and
comparisons were made between them. It was found that PairedData's
method's results match this method, SAS, and one of the other R
methods. A notable discrepancy was the DescTools implementation of the
function, which only sometimes agreed with SAS, WRS2, PairedData and
this implementation. For this reason, most comparisons in R are made
against PairedData's method.

Rather than providing the input and output for all evaluations, here is
a representative example:
> library(PairedData)
> a <- c(1, 2, 3)
> b <- c(1.1, 2.9, 4.2)
> options(digits=16)
> yuen.t.test(a, b, tr=.2)

    Two-sample Yuen test, trim=0.2

data:  x and y
t = -0.68649512735573, df = 3.4104431643464, p-value = 0.5361949075313
alternative hypothesis: true difference in trimmed means is not equal
to 0
95 percent confidence interval:
 -3.912777195645217  2.446110528978550
sample estimates:
trimmed mean of x trimmed mean of y
2.000000000000000 2.73333333333333
FrE	  r  r2  r3  Nri   r  r   )rn   r9  rE  r4  r  rE	  r*  r)  s           rw   test_ttest_compare_r$Test_ttest_trim.test_ttest_compare_r  s.    @ "OOAtuM		E2/rz   c                 p    / SQn/ SQn[         R                  " XSSS9u  p4[        USSS9  [        US	SS9  g )
N)r^   rZ   r  r  r  ,   r^   rZ   r  r  r  rn	  )rd   r  rZ   r^   r     r  rd   r  rZ   r^   r  ro	  r  g
ףp=
?Fri	  gRbv?r  r3  gOi?rj	  rn   r9  rE  r*  r)  s        rw   test_compare_SAS Test_ttest_trim.test_compare_SAS&  s=     =D "OOAseL	t4	8$7rz   c                 n    / SQn/ SQn[         R                  " XSS9u  p4[        USSS9  [        USSS9  g	)
a^  
The PairedData library only supports unequal variances. To compare
samples with equal variances, the multicon library is used.
> library(multicon)
> a <- c(2.7, 2.7, 1.1, 3.0, 1.9, 3.0, 3.8, 3.8, 0.3, 1.9, 1.9)
> b <- c(6.5, 5.4, 8.1, 3.5, 0.5, 3.8, 6.8, 4.9, 9.5, 6.2, 4.1)
> dv = c(a,b)
> iv = c(rep('a', length(a)), rep('b', length(b)))
> yuenContrast(dv~ iv, EQVAR = TRUE)
$Ms
   N                 M wgt
a 11 2.442857142857143   1
b 11 5.385714285714286  -1

$test
                      stat df              crit                   p
results -4.246116897032513 12 2.178812829667228 0.00113508833897713
rd	  rf	  r  rE	  gR?r  r3  g^Nrj	  rp	  s        rw   test_equal_varTest_ttest_trim.test_equal_var5  s<    & DC!OOAr:	 3%@	#5EBrz   z	alt,pr,tr))r  gjΜ>5?rg	  )r~  gn4aƂW?rg	  c                 n    / SQn/ SQn[         R                  " XESSUS9u  pg[        XrSS9  [        XcSS9  g)	z
> library(PairedData)
> a <- c(2.7,2.7,1.1,3.0,1.9,3.0,3.8,3.8,0.3,1.9,1.9)
> b <- c(6.5,5.4,8.1,3.5,0.5,3.8,6.8,4.9,9.5,6.2,4.1)
> options(digits=16)
> yuen.t.test(a, b, alternative = 'greater')
rd	  rf	  r  F)rE	  r  r  r  r3  Nrj	  )rn   r  r4  r  r9  rE  r*  r)  s           rw   test_alternatives!Test_ttest_trim.test_alternativesO  s=     DC!OOArU8;=	/	E2rz   c           
         Sn[        [        US9   Sn[        R                  " [        US9   [
        R                  " SS/SS/SSS9  S S S 5        S S S 5        [        [        US9   S	n[        R                  " [        US9   [
        R                  " SS/SS/SSSS
9  S S S 5        S S S 5        g ! , (       d  f       Nn= f! , (       d  f       Nw= f! , (       d  f       N9= f! , (       d  f       g = f)Nz>Use of `permutations` is incompatible with with use of `trim`.r   z5Arguments {'permutations'} are deprecated, whether...r   r1   r2   r  )rE	  r  z9Arguments {.*'random_state'.*} are deprecated, whether...)rE	  r  r  )r   r  rP  rQ  r  ri   r  )rn   r   r  s      rw   test_errors_unsupported'Test_ttest_trim.test_errors_unsupportedc  s    P.e<MG0@AARaH A =
 .e<QG0@AARa-.0 A =< A@ =< A@ =<sF   CB1	C'C$C C$1
B?	;C
C
C!	C$$
C2Tr  r  rH   c                 ,   SnUR                  S5      UR                  S5      S-   pC[        U5      (       a  [        R                  " X4SS9  g [        R
                  " [        US9   [        R                  " X4SS9  S S S 5        g ! , (       d  f       g = f)Nz3Use of `trim` is compatible only with NumPy arrays.r\   r   r1  rt	  r   )r   r+   ri   r  rP  r   r  )rn   ro   r  r9  rE  s        rw   r<	  5Test_ttest_trim.test_permutation_not_implement_for_xpq  sf    
 Hyy}biimAo1B<<OOAs+2'B3/ CBBs   &B
BrE	  )gɿr:   r   c                     Sn[        [        US9   [        R                  " SS/SS/US9  S S S 5        g ! , (       d  f       g = f)Nz/Trimming percentage should be 0 <= `trim` < .5.r   r   r1   rt	  )r   r   ri   r  )rn   rE	  r   s      rw   test_trim_bounds_error&Test_ttest_trim.test_trim_bounds_error~  s5    A:U3OOQFQF6 433s	   5
Ar   N)r   r   r   r   rA	  rP  r  r  rk	  rq	  ru	  rx	  r{	  r'   rH   r  r<	  r	  r   r   rz   rw   rb	  rb	    sE   	O%8:M			1?	/	5	1?	/	6	@	@	,b	2
H
  "34Db	JKF& [[-v6!0 7!0F8C4 [[[N3	3 0 [[!!4)D " F[[/00 1F 0 [[V\27 37rz   rb	  c                   (   \ rS rSr\R
                  " SS9r/ SQ\S'   SSS\R                  * S	/\S
'   SSSS\R                  /\S'   / SQ\S'   SSS\R                  * S/\S'   SSSS\R                  /\S'   SSS\R                  \R                  /\S'   SSS\R                  \R                  /\S'   SSS\R                  \R                  /\S'   S S!S"\R                  \R                  /\S#'   S S!S$\R                  \R                  /\S%'   S S!S&\R                  \R                  /\S''   \	R                  R                  S(/ S)Q5      \	R                  R                  S*S+S,/5      \	R                  R                  S-S.S//5      S0 5       5       5       rS1rg2)3Test_ttest_CIi  )r2   r1   r1   r4   )r  )gͿe13@gv7?gę"Ͽg8 {M(?rq  r	  r	  gv7?gx_?r  g
/?gD .ɿ)r1   r   r   )reϿ-</&@g?JJ?gbտg3Պ?)r   r   r   r	  r	  g?JJ?gF?)r   r   r   g{?gads2ѿ)r1   r   r   gs"%οr  gW"?)r   r   r   gW"?r   r   r   g:T'?)r1   r   r   g:пrZ   g0:5?r  g0:5?r  g be?)r1   r   r   r  r=  r  FTrE	  r   r  c                    U(       a  U(       a  [         R                  " S5        U(       a&  [        U5      (       d  [         R                  " S5        [        R
                  R                  S5      nUR                  UR                  S5      5      nUR                  UR                  S5      5      n[        R                  " XgUX#S9nSSS	S
.n	U R                  X   [        U5      [        [        R                  " U5      5      4   n
U
u  ppnSn[        UR                  UR                  U5      US9  [        UR                  UR                  U5      US9  [        UR                   UR                  U5      US9  U(       dZ  UR#                  S5      n[        UR$                  UR                  U5      US9  [        UR&                  UR                  U5      US9  g g )Nz3Discrepancy in `main`; needs further investigation.z*`trim` is only compatible with NumPy inputl   'Nk' r]   r_   )r  r  rE	  r   r   r1   r=  r  r  r3  )rP  xfailr+   rz  r   r  r  rf   ri   r  r   r%  ceilr/   r*  r  r)  ro  rr  rs  )rn   r  r  rE	  ro   r  rp   rq   r   r  r  r*  r  r)  rr  rs  r  r  s                     rw   test_confidence_interval&Test_ttest_CI.test_confidence_interval  s_    LLNOKKDEii##$78JJszz"~&JJszz"~&ooa(1> &'a@ff\.IBGGDM@RRS+.(	vDrzz)'<4H

2T:

BJJv$6TB((-BBFFBJJsO$?BGGRZZ%5DA rz   r   N)r   r   r   r   r   rC  r   r  rm   rP  r  r  r	  r   r   rz   rw   r	  r	    s   B 	|$ANAgJibffWlKAgJiM266JAgJLAgJibffWlKAgJiL"&&IAgJ%r+=rvvrvvNAgJ%r+=rvvrvvNAgJ%r+=rvvrvvNAgJ%r+=rvvrvvNAgJ%r+=rvvrvvNAgJ%r+=rvvrvvNAgJ[[],LM[[[5$-8[[VaX.B / 9 NBrz   r	  c            	      *   [         R                  R                  S5        [         R                  R                  SSSSSS5      n [         R                  R                  SSSSS5      n[	        X4S	S
9n[         R
                  " U S5      n [         R
                  " US   S5      n[        S UR                   5       6  HT  nUu  pEpgpXpR                  S	   :  a  XXVXxU	4   X$XVXxU	4   :X  d   eM1  XXVXpR                  S	   -
  X4   X$XVXxU	4   :X  a  MT   e   g )Nr   r4   r3   r2   r   r5   r7   r1   rc   rV   rJ	  )N.rK	  c              3   8   #    U  H  n[        U5      v   M     g 7fr  rM	  rN	  s     rw   rP	  .test__broadcast_concatenate.<locals>.<genexpr>  s     5W588WrR	  )r   r  rn  r|  r   rS	  r   r  )
r9  rE  rY  indexr  r  r~  r'  r  r  s
             rw   test__broadcast_concatenater	    s    IINN1
		q!Q1a(A
		q!Q1%AvB/A
%&A
)01A5QWW56 aAwwr{?aA%&!qQ1,<*====a''"+oq34Q1:J8KKKK 7rz   c                 <   U R                  / SQ5      nU R                  / SQ5      nU R                  S5      nU R                  S5      n[        R                  " XSS9u  pV[        XT5        [        Xc5        [        R                  " [        X5      SS06u  pV[        XT5        [        Xc5        U R                  / SQ5      nU R                  S	5      nU R                  S
5      n[        R                  " XSS9u  pV[        XT5        [        Xc5        [        R                  " [        X5      SS06u  pV[        XT5        [        Xc5        U R                  S5      nU R                  S5      nU R                  S5      nU R                  S5      nU R                  XD* /5      n	U R                  X3/5      n
U R                  SSS5      nU R                  SSS5      nU R                  SSS5      nU R                  X/5      nU R                  X/5      n[        R                  " XSSS9u  pV[        XT5        [        Xc5        [        R                  " [        X5      SS06u  pV[        XT5        [        Xc5        [        R                  " XSSS9u  pV[        XW5        [        Xh5        [        R                  " [        X5      SS06u  pV[        XW5        [        Xh5        [        R                  " UR                  UR                  SSS9n[        UR                  U	5        [        UR                  U
5        [        UR                  UR                  5      n[        R                  " USS06n[        UR                  U	5        [        UR                  U
5        [        R                  " XSSS9n[        UR                  U	5        [        UR                  U
5        [        XSS9n[        R                  " USS06n[        UR                  U	5        [        UR                  U
5        g )Nr  rc	  g9(?geFr  r  r0  gJ?g9ʿr  g@[?gωұ?ghG?r   r  r  r4   r  r   r  rV   )rf   ri   r  r/   r  r  r!  r  r  r*  r)  )ro   r9  rE  r4  r  r  rT  	tr_uneq_n	pr_uneq_nr  r  rvs3r  r  r  r  r   r0  s                     rw   test_ttest_ind_with_uneq_varr	    sE    	

< A


?#A	'	(B	)	*B??151DAAA%%{1'8JEJDAAA


#$A	'	(B	)	*B??151DAAA%%{1'8JEJDAAA 
&	'B

./I	'	(B

./IJJCy!EJJx E;;q#r"D;;q#s#D;;q#s#Dhh|$Ghh|$G??4A?DAAA%%{4'>P%PDAAA??4A?DAA!A!%%{4'>P%PDAA!A!
//'))WYYQ%
HCCMM5)CJJ&wyy')),D

$
$d
<e
<CCMM5)CJJ&
//'e
DCCMM5)CJJ&wa0D

$
$d
<e
<CCMM5)CJJ&rz   c                    U R                  S5      nU R                  S5      n[        R                  " [        SS9   [
        R                  " XSS9u  p4S S S 5        [        WU R                  U R                  * 5      5        [        WU R                  S5      5        [        R                  " SS9   [
        R                  " XSS9u  p4[        X0R                  U R                  5      5        [        X@R                  U R                  5      5        U R                  S	U R                  /S
S	//5      n[
        R                  " XPR                  S5      SS9u  p4[        X0R                  S[        R                  /5      5        [        X@R                  S[        R                  /5      5        S S S 5        g ! , (       d  f       GNh= f! , (       d  f       g = f)Nr2   r  r   Fr	  r   r}  rc  r   rb   r1  r   )rH  r  rP  rQ  r   ri   r  r0   rf   r  r   r  rm   )ro   rp   rq   r  rT  r  s         rw   test_ttest_ind_zero_divisionr	  ;  sA    	A

A	n,E	Fqu5 
GArzz266'*+Arzz"~&		"qu5::bff-.::bff-. zzArvv;Q01tXXf%5G::r266l34::r266l34 
#	" 
G	F
 
#	"s   F51C;G5
G
Gc                  b   [         R                  SSS/n / SQn[        R                  " XSS9n[        R                  " XSS9n[	        UR
                  UR
                  * SS9  [	        UR                  UR                  SS9  [        R                  " XS	S  5      n[	        X4SS9  [	        US
SS9  g )Nrm  r1  r   r  r   r   r2  r3  r   )g8HgW@?)r   rm   ri   r  r   r*  r)  r  s        rw   test_ttest_ind_nan_2nd_argr	  T  s    	c3AA	&	1B	&	1BBLL2<<-e<BIIryyu5 
abE	"BB' BC rz   c                 R   [        U 5      (       a\  [        R                  " [        [        S9   [
        R                  " U R                  / 5      U R                  / 5      5      nS S S 5        O5[
        R                  " U R                  / 5      U R                  / 5      5      n[        W[
        R                  R                  5      (       d   eU R                  U R                  5      S   n[        UR                  U5        [        UR                  U5        g ! , (       d  f       N= f)Nr   r   )r+   rP  rQ  r   r   ri   r  rf   r#  r  r  rm   r0   r*  r)  )ro   r   r  s      rw   #test_ttest_ind_empty_1d_returns_nanr	  j  s     ||\\,4IJ//"**R."**R.AC KJ oobjjnbjjn=c5??667777
**RVV
R
 CCMM3'CJJ$ KJs   6D
D&r{   r|   c                    UR                  S5      nUR                  U 5      n [        R                  R	                  5        nUR                  [        [        5        [        R                  " X0SS9nS S S 5        [        W[        R                  R                  5      (       d   eUR                  XR                  S9n[        UR                   U5        [        UR"                  U5        g ! , (       d  f       N= fr  )rC  rf   r   r  r   r   r   r   ri   r  r#  r  r  r   rm   r0   r*  r)  )rE  r  ro   r9  r   r   r  s          rw   test_ttest_ind_axis_size_zeror	  y  s     	A


1A		%	%	'3

%'<=ooa, 
( c5??667777WW^W?NCMM>2CJJ/ 
(	's   0C**
C8c                 8   U R                  S5      nU R                  S5      n[        R                  " XSS9n[        U[        R                  R
                  5      (       d   eUR                  R                  S:X  d   eUR                  R                  S:X  d   eg r  	rC  ri   r  r#  r  r  r*  r  r)  ro   r9  rE  r   s       rw    test_ttest_ind_nonaxis_size_zeror	    s}     	A
A
//!Q
'Cc5??667777=='''::v%%%rz   c                 8   U R                  S5      nU R                  S5      n[        R                  " XSS9n[        U[        R                  R
                  5      (       d   eUR                  R                  S:X  d   eUR                  R                  S:X  d   eg )N)r   r6   r   r  r   rV   r  r	  r	  s       rw   2test_ttest_ind_nonaxis_size_zero_different_lengthsr	    s}     	A
A
//!Q
'Cc5??667777=='''::v%%%rz   z"Other backends don't like integersr   c                    U R                  SS/5      U R                  SS/5      p!U R                  SS/5      U R                  SS/5      pCU R                  SS/5      U R                  SS	/5      pe[        R                  " XXRXF5        g )
Nr   r1   r2   r3   r4         r     )rf   ri   r  )ro   mean1mean2std1std2nobs1nobs2s          rw   test_gh5686r	    sy    
 ::q!f%rzz1a&'95QF#RZZA%7$::sCj)2::sCj+A5	uE$Frz   c           
         U R                  S5      nU R                  S5      nU R                  U R                  5      n[        R                  " XX!XSS9n[	        UR
                  U5        [	        UR                  U5        g )Nr   r   Fr	  )rf   rm   ri   r  r0   r*  r)  )ro   zerosixr  r   s        rw   %test_ttest_ind_from_stats_inputs_zeror	    sc     ::b>D
**R.C
**RVV
C

$
$TDQV
WCCMM3'CJJ$rz   c                 f   [         R                  R                  S5      nU R                  UR	                  SS95      nU R                  UR	                  SS95      nUR                  SS9n[        R                  " X#SSS9n[         R                  " UR                  5      n[        R                  " U[        R
                  " 5       R                  5      R                  S	:  d   e[        [         R                  " Xd5      US
S9  [        R                  " X2SSS9n[         R                  " UR                  5      n[        R                  " U[        R
                  " 5       R                  5      R                  S	:  d   e[        [         R                  " Xd5      US
S9  U R                  / SQ5      U R                  S/5      p2[        R                  " X#SS9n[        U 5      (       a  SOSn[        UR                  U R                  S5      US9  [        UR                  U R                  S5      US9  g )Nl   bQ )rm  r1   r  )rm  r   r  Trb   )r  rW   r1  r  r3  )r1   r2   r4   r;   r	  r  r  gzNd?r  gJ?)r   r  r  rf   r  r  ri   r  r)  r  r  r   quantiler,   r/   r*  )ro   r  rp   rq   r6  r   r)  r  s           rw   test_ttest_uniform_pvaluesr	    s    ))


0C


3::::./A


3::::./AA
//!$R
8CZZ

#F>>&%--/"5"56==CCCBKK*AD9
//!$R
8CZZ

#F>>&%--/"5"56==CCCBKK*AD9
 ::i "**cU"3q
//!$
/CB<<4UDCMM2::o#>TJCJJ

> :Frz   c                     UR                  US:H  5      nUR                  US:H  5      nU S:  U-  U S:  U-  -  nUR                  XaS-  SUS-  -
  5      $ )Nr~  r  r   r1   r   )rf   rP  )r  rT  r  ro   r~  r  r  s          rw   _convert_pvalue_alternativer	    sa     ::cVm$Djj	)*G
a%4QUg-.A88AsA!G$$rz   c                    Su  pn[         R                  R                  SSXU4S9nU R                  U5      nU R	                  SX#45      n[         R
                  " XESS9u  pg[         R
                  " USSS9u  p[         R
                  " US S 2SS4   S5      u  p[        XhS	S
9  [        US   U
S	S
9  [        UR                  X#45        U R	                  USU45      n[         R
                  " XESS9u  pg[         R
                  " USSS9u  p[         R
                  " USS S 2S4   S5      u  p[        XhS	S
9  [        US   U
S	S
9  [        UR                  X45        U R	                  XS45      n[         R
                  " XESS9u  pg[         R
                  " USSS9u  p[         R
                  " USSS S 24   S5      u  p[        XhS	S
9  [        US   U
S	S
9  [        UR                  X45        [         R
                  " U R                  / SQ5      S5      u  p[        U R                  U5      U R                  U R                  5      5        [        XR                  S5      5        [         R
                  " US S 2S S 2S S 24   S5      u  p[         R
                  " US S 2S S 2S S 24   SSS9u  p[        XSU 5      n[        UU5        [        X5        [         R
                  " US S 2S S 2S S 24   SSS9u  p[        XSU 5      n[        UU5        [        X5        [        R                  " SS9   [         R
                  " U R                  / SQ5      S5      n[        UR                  U R                  U R                   5      5        [        UR"                  U R                  U R                   5      5        U R                  S[        R                   /SS//5      n[         R
                  " US5      n[        UR                  U R                  SU R                   /5      5        [        UR"                  U R                  SU R                   /5      5        S S S 5        g ! , (       d  f       g = f)Nr\   r  r  r4   r\   r  r   r   rV   r   rX  r  r  r1   )r   r   r   r   r  r  r~  r}  r	  r>  )ri   rG  r  rf   r  r  r/   r   r  r0   r  r  r	  r   r  r*  rm   r)  )ro   rb  rc  n3rvn1r  re  r  rf  p2rg  p3r  rT  r  r4  pcr   r  s                      rw   test_ttest_1samp_newr	    s    JBB::>>ar>=D::dD ggq"k"Gt15FBtRa0FBtAq!G}b1FBB'BtHbu-B8$ggr1bk"Gt15FBtRa0FBtAq!G}b1FBB'BtHbu-B8$ggrqk"Gt15FBtRa0FBtAq!G}b1FBB'BtHbu-B8$ RZZ5r:DABFF1Irzz"&&12Azz"~&tAq!G}b1FBT!Q']BIFDA	$RY	;BArAT!Q']BFCDA	$RVR	8BArA		"

< 8"=rzz"&&'9:

BJJrvv$67 zzB<#r34b)rzz2rvv,'?@

BJJBFF|$<= 
#	"	"s   0D%Q
Q,z(Only NumPy has nan_policy='omit' for nowc                 
   Su  pn[         R                  R                  SSXU4S9nU R                  U5      nU R                  USS2SS2S	S
24'   [         R
                  " US S 2S S 2S S 24   SSS9u  pV[         R
                  " US S 2S S 2S S 24   SSSS9u  px[        XVSU 5      n	[        X5        [        Xu5        [         R
                  " US S 2S S 2S S 24   SSSS9u  px[        XVSU 5      n	[        X5        [        Xu5        g )N)r4   r\   r  r4   r\   r  r   r1   r   r2   r3   r7   r   r   r   r  rQ  r~  )ri   rG  r  rf   rm   r  r	  r/   )
ro   rb  rc  r	  r	  r  r4  r  rT  r	  s
             rw   test_ttest_1samp_new_omitr	  0  s    
 JBB::>>ar>=D::dD&&D1ac1Q3tAq!G}bVDFBT!Q']B6)24DA	$RY	;BAAT!Q']B6)/1DA	$RVR	8BAArz   c                    [         R                  R                  S5      nUR                  SS9nU R                  U5      nSnU R                  UR                  SS95      n[        R
                  " [        US9   [        R                  " X$SS9  S S S 5        U R                  UR                  S	S95      n[        R                  " X$SS9nUR                  R                  S
:X  d   e[        U5      nUR                  5       u  pxUR                  USS9nUR                  USS9n[        R                  " X'SS9nU R                  U R                  SU R                  S9UR                   R                  5      n	[#        UR                   U	5        [        R                  " X(SS9n[#        UR                   U	5        g ! , (       d  f       GN0= f)Nl   iI}pC )r   r  r  r  z%`popmean.shape\[axis\]` must equal 1.)r4   r1   r  r   rQ  )r  rW   )r4   r   r  )r4   r  rV   g?rZ  )r   r  r  rf   rP  r   r   ri   r  r*  r  r)   ro  rI  r]  r   r)  r/   )
ro   r  rp   r  r  r   r   r'  r  r  s
             rw   test_ttest_1samp_popmean_arrayr	  J  st    ))

 3
4C


$A


1A6Gjj45G	z	1!26 
2 jj45G


AR
8C==')))a G""$DAAB'AAB'A


Ar
2C
//"**T*<cjj>N>N
OCCJJ$


Ar
2CCJJ$# 
2	1s   9F88
Gc                   p   \ rS rSr\S 5       r\" SSS9\R                  R                  S5      \S 5       5       5       r
S r\S	 5       rS
 r\" SSS9\R                  R                  S5      \S 5       5       5       r\" SSS9\R                  R                  S5      \S 5       5       5       r\S 5       rSrg)TestDescribeil  c                    [        5        n[        R                  " SSS9   UR                  [        S5        [
        R                  " UR                  S5      S   5      u  p4pVpxS S S 5        S S S 5        WS:X  d   e[        WS   UR                  S5      5        [        US   UR                  S5      5        [        WUR                  S5      5        [        WUR                  UR                  5      5        [        WUR                  UR                  5      5        [        WUR                  UR                  5      5        g ! , (       d  f       N= f! , (       d  f       N= f)Nr}  r  r  r   r   r   r   )
r   r   r  r   r   ri   describerf   r0   rm   )	rn   ro   r   r  r~  r  r  skkurts	            rw   test_describe_scalar!TestDescribe.test_describe_scalarm  s     Ckk(8<JJ~'JK$)NN2::b>"3E$F!A1 = ! Avv1rzz#/1rzz#/2::c?+2::bff-.BJJrvv./bjj01 =< ! s#   EAE$E
E	E
E"r{   r|   rE   rH   c                    [        UR                  S5      5      nUR                  UR                  S5      UR	                  SS5      45      nSnUR                  / SQ5      UR                  / SQ5      4nUR                  / SQ5      nUR                  / S	Q5      nUR                  S
/S-  5      nUR                  S/S-  5      n	[
        R                  " U5      u  pppX:X  d   e[        US   US   5        [        US   US   5        [        XSUR                  UR                  5      R                  -  S9  [        XSUR                  UR                  5      R                  -  S9  [        X5        [        X5        [
        R                  " UR                  SS9u  pppX:X  d   e[        US   US   5        [        US   US   5        [        XSUR                  UR                  5      R                  -  S9  [        XSUR                  UR                  5      R                  -  S9  [        X5        [        X5        g )Nr   r  r1   r3   rm  r4   r   r   r   r   rm  rm  rm  rm  ffffff?r	  r	  r	  )r4  r4  r4  r4  H,p ?r3   TUUUUUr   r   r  rV   )r)   rf   r  r  r   ri   r	  r0   r/   r   rX  epsr  rn   ro   r   rp   ncmmcmcvcskckurtcr  r~  r  r  r	  r	  s                   rw   test_describe_numbers"TestDescribe.test_describe_numbers{  s    ""**R.1NNBGGFORWWVR-@ABzz*+RZZ8H-IJZZ,-ZZ,-jj-.23

./!34 %q 1qRww1s1v&1s1v&A(9(=(=$=>A(9(=(=$=> $ %qss ;qRww1s1v&1s1v&A(9(=(=$=>A(9(=(=$=> $rz   c                 "   [         R                  " S5      n[         R                  US'   Su  p#SnSnSnSn[        R                  " USS	9u  ppp[        X5        [        X5        [        X5        [        X5        [        X5        [        XS
S9  g )Nr   r8   )r8   )r   r   r   rA   r   gGzr   r   r_   rS  )r   r   rm   ri   r	  r   r   )rn   rp   r	  r	  r	  r	  r	  r	  r  r~  r  r  r	  r	  s                 rw   describe_nan_policy_omit_test*TestDescribe.describe_nan_policy_omit_test  s    IIcNvv!!# %qV DqRQRQQ!"*!$r:rz   c                    UR                  S5      nUR                  US:H  UR                  UR                  5      U5      nSn[        R
                  " [        US9   [        R                  " USS9  S S S 5        [        R                  " USS9u  pEpgpUR                  UR                  5      S   n
US	:X  d   e[        US
   U
5        [        US   U
5        [        Xj5        [        Xz5        [        X5        [        X5        [        U5      (       a  U R                  5         O9Sn[        R
                  " [        US9   [        R                  " USS9  S S S 5        Sn[        R
                  " [        US9   [        R                  " USS9  S S S 5        g ! , (       d  f       GN,= f! , (       d  f       NZ= f! , (       d  f       g = f)Nr   r8   r   r   r   r   r  r   r\   r   r   z9`nan_policy='omit' is incompatible with non-NumPy arrays.r   r   r   )r   rP  rf   rm   rP  r   r   ri   r	  r0   r+   r	  )rn   ro   rp   r  r  r~  r  r  r	  r	  r  s              rw   test_describe_nan_policy_other+TestDescribe.test_describe_nan_policy_other  sP   IIcNHHQT2::bff-q11]]:W5NN11 6 !&q[ IqRjj $Bww1s#1s# "B<<..0QGz9qV4 : 1]]:W5NN12 65+ 65" :9 65s$   F?F)8F:
F&)
F7:
Gc                 r    [         R                  " [        R                  " S5      5      nSn[	        X5        g )NrO   )r  minmaxrl   variancer  r  )ri   r	  r   r   r   )rn   r  r,  s      rw   test_describe_result_attributes,TestDescribe.test_describe_result_attributes  s'     		".S
F/rz   c                 l   [        UR                  S5      5      nUR                  UR                  S5      UR	                  SS5      45      nSnUR                  / SQ5      UR                  / SQ5      4nUR                  / SQ5      nUR                  / S	Q5      nUR                  S
/S-  5      nUR                  S/S-  5      n	[
        R                  " USS9u  pppX:X  d   e[        US   US   5        [        US   US   5        [        X5        [        X5        [        X5        [        X5        g )Nr   r  r	  rm  r4   r	  r	  r	  )Q?r	  r	  r	  r	  r3   r	  r   rM  r   	r)   rf   r  r  r   ri   r	  r0   r/   r	  s                   rw   test_describe_ddofTestDescribe.test_describe_ddof  s    ""**R.1NNBGGFORWWVR-@ABzz*+RZZ8H-IJZZ,-ZZ01jj-.23

./!34 %qq 9qRww1s1v&1s1v& $rz   c                 L   [        UR                  S5      5      nUR                  UR                  S5      UR	                  SS5      45      nSnUR                  S5      UR                  S5      4nUR                  S5      nUR                  S5      nUR                  S5      nUR                  S	5      n	[
        R                  " US S
9u  pppX:X  d   e[        US   US   5        [        US   US   5        [        X5        [        X5        [        X5        [        X5        g )Nr   r  r	  rm  r  r	  ga+?gE,p ?gUUUUUUrV   r   r   r	  r	  s                   rw   test_describe_axis_none$TestDescribe.test_describe_axis_none  s     ""**R.1NNBGGFORWWVR-@AB zz#

30ZZ*+ZZ+,jj+,

./ !&qt <qRww1s1v&1s1v& $rz   c                     Sn[         R                  " [        US9   [        R                  " UR                  / 5      5        S S S 5        g ! , (       d  f       g = f)NzThe input must not be empty.r   )rP  r   r   ri   r	  rf   )rn   ro   r  s      rw   test_describe_empty TestDescribe.test_describe_empty  s5    0]]:W5NN2::b>* 655s   &A
Ar   N)r   r   r   r   r'   r	  rH   rP  r  r  r	  r	  r	  r	  r	  r	  r	  r   r   rz   rw   r	  r	  l  s    2 2 f%56[[/0%  1 7%6;" 3 3:0 f%56[[/0%  1 7%$ f%56[[/0%  1 7%. + +rz   r	  c                      \ rS rSrS r\" SSS9\R                  R                  S5      \R                  R                  S/ SQ5      S	 5       5       5       r
\" SSS9\R                  R                  S5      S
 5       5       rSrg)NormalityTestsi  c                    [        [        U R                  5      nUR                  S5      n[	        U5      (       av  [
        R                  " [        [        S9   U" U5      nUR                  UR                  5      n[        UR                  U5        [        UR                  U5        S S S 5        g Sn[
        R                  " [        US9   U" U5        S S S 5        g ! , (       d  f       g = f! , (       d  f       g = f)Nr   r   z...requires at least...)r[  ri   	test_namerf   r+   rP  rQ  r   r   rm   r0   r*  r)  r   r   )rn   ro   r  rp   r   r  r  s          rw   test_too_smallNormalityTests.test_too_small  s    5$..1JJrNB<<08MNqkjj(s3

C0	 ON 0Gz9 :9 ON :9s   AC	C0
C-0
C>r{   r|   rE   rH   r  r=  c                    U R                   n[        [        U5      nUR                  U R                  S   5      nUR                  U R                  S   5      n0 nUS;   aA  US;   a%  US:X  a  US-  OSUS-  -
  nUS:X  a  SU-
  OUnXS'   O[
        R                  " S	5        UR                  S
5      S-  nU" U40 UD6n	U	u  p[        X5        [        X5        [        U	SUS9  g )Nr   r   >   r~  r  >   skewtestkurtosistestr~  r1   r	  r  z,`alternative` not available for `normaltest`)rQ  rb   r   r   r1   r1  rQ  rb   r   r   r1   r1  rQ  rb   r   r   r1   r1  rQ  rb   r   r   r1   r1  r  r  )	r	  r[  ri   rf   case_refrP  rz  r/   r   )rn   r  ro   r	  r  ref_statisticrO  r1  rp   r   res_statistic
res_pvalues               rw   test_against_RNormalityTests.test_against_R  s     NN	5),zz$--"23ZZa 01
--88-8F-BZ\*UV,
-6*-DQz\*
(3}%JKJJ./2q#F#$'!5
/C!8R@rz   c                    [        [        U R                  5      nUR                  S5      nUR	                  UR
                  UR                  S9nUR                  US:H  XC5      n[        R                  " SS9   U" U5      n[        UR                  U5        [        UR                  U5        S S S 5        g ! , (       d  f       g = f)Nr  rZ  ro	  r}  r~  )r[  ri   r	  r   rf   rm   rX  rP  r   r  r0   r*  r)  )rn   ro   r  rp   r  r   s         rw   test_nanNormalityTests.test_nan7  s     5$..1IIcNjjqwwj/HHQ"Wc%[[*1+CCMM3/CJJ, +**s   95B77
Cr   N)r   r   r   r   r	  rH   rP  r  r  r  r
  r
  r   r   rz   rw   r	  r	    s     f%56[[/0[[],LMA N 1 7A< f%56[[/0	- 1 7	-rz   r	  c                   (    \ rS rSrSrSrS rS rSrg)TestSkewTestiD  r	  )gvO?gbH`?c                     [         R                  R                  SSSS9nUR                  U5      n[         R                  " USS9R
                  n[        XAR                  SUR                  S9S	S
9  g )Nr   rm  {   )r9  r  r  r  r  r   rZ  g?̔>r3  )ri   skewnormr  rf   r	  r)  r/   rX  )rn   ro   r  a1_xpr  s        rw   test_intuitiveTestSkewTest.test_intuitiveH  s[    ^^!%cB

2~~e;BBjjEKKj@tLrz   c                 P   [         R                  " UR                  S5      5        UR                  S5      n[        U5      (       a  [        R
                  " [        [        S9   [         R                  " U5      nUR                  UR                  5      n[        UR                  U5        [        UR                  U5        S S S 5        g Sn[        R                  " [        US9   [         R                  " U5        S S S 5        g ! , (       d  f       g = f! , (       d  f       g = f)Nr   r   r   z+`skewtest` requires at least 8 observations)ri   r	  r   r+   rP  rQ  r   r   rf   rm   r0   r*  r)  r   r   rn   ro   rp   r   r  r  s         rw   "test_skewtest_too_few_observations/TestSkewTest.test_skewtest_too_few_observationsO  s     	ryy~&IIcNB<<08MNnnQ'jj(s3

C0	 ON DGz9q! :9 ON :9s   $AD&D
D
D%r   N)	r   r   r   r   r	  r
  r
  r
  r   r   rz   rw   r
  r
  D  s    I9HM"rz   r
  c                      \ rS rSrSrSr\" SSS9\R                  R                  S5      S 5       5       r
\" SSS9\R                  R                  S5      S	 5       5       r\" SSS9\R                  R                  S5      S
 5       5       rSrg)TestKurtosisTestia  r 
  )gglg2J@?r{   r|   rE   rH   c                     [         R                  R                  SSS9nUR                  U5      n[         R                  " USS9R
                  n[        XAR                  SUR                  S9SS	9  g )
Nrm  r
  )r  r  r  r  r   rZ  r2  r3  )ri   laplacer  rf   r 
  r)  r/   rX  )rn   ro   r  a2_xpr  s        rw   r
  TestKurtosisTest.test_intuitivee  s]     ]]E<

2!!%Y?FFjjEKKj@uMrz   c           
         / SQn[         R                  " [        U5       VVs/ s H  u  p4[         R                  " XC5      PM     snn5      nUR	                  XQR
                  S9n[        R                  " U5      S   S:  d   eg s  snnf )N)
r/  r   :   r6   r   )   r   r   r      rZ  r   r  )r   rH  	enumerater   rf   r   ri   r 
  )rn   ro   r  r  rY  rp   s         rw   test_gh9033_regression'TestKurtosisTest.test_gh9033_regressionn  so    
 7II61BC1Brwwq}1BCDJJq

J+!!!$Q'$... Ds   "B
c                    [         R                  " UR                  S5      5        Sn[        R                  " [
        US9   [         R                  " UR                  S5      5        S S S 5        [        R                  " [
        US9   [         R                  " UR                  S5      5        S S S 5        UR                  S5      n[        U5      (       a  [        R                  " [        [        S9   [         R                  " U5      nUR                  UR                  5      n[        UR                  U5        [        UR                  U5        S S S 5        g Sn[        R                  " [         US9   [         R                  " U5        S S S 5        g ! , (       d  f       GN6= f! , (       d  f       GN= f! , (       d  f       g = f! , (       d  f       g = f)Nr  z+`kurtosistest` p-value may be inaccurate...r   rO   g      3@r   z/`kurtosistest` requires at least 5 observations)ri   r 
  r   rP  rQ  rI  r+   r   r   r	  rf   rm   r0   r*  r)  r   r   )rn   ro   r  rp   r   r  s         rw   &test_kurtosistest_too_few_observations7TestKurtosisTest.test_kurtosistest_too_few_observationsx  s-    	299T?+?\\+W5ryy~. 6\\+W5ryy/ 6 IIcNB<<08MNnnQ'jj(s3

C0	 ON HGz9""1% :9 6555
 ON :9s1   &F&F(4AF:6G
F%(
F7:
G
Gr   N)r   r   r   r   r	  r
  rH   rP  r  r  r
  r!
  r$
  r   r   rz   rw   r
  r
  a  s    I:Hf%56[[/0N 1 7N f%56[[/0/ 1 7/ f%56[[/0& 1 7&rz   r
  c                       \ rS rSrSrSrSrg)TestNormalTesti  
normaltest)gاc@g?r   N)r   r   r   r   r	  r
  r   r   rz   rw   r'
  r'
    s    I9Hrz   r'
  c                       \ rS rSr\R
                  R                  S5        \R
                  R                  SS5      u  rr	\
R                  R                  S/ SQ5      S 5       rS rS	 rS
rg)TestRankSumsi  r   r1   r\   r  r  c                     [         R                  " U R                  U R                  US9R                  n[         R
                  " U R                  U R                  SUS9R                  n[        X#5        g )Nr  F)use_continuityr  )ri   ranksumsrp   rq   r)  mannwhitneyur   )rn   r  r  r  s       rw   test_ranksums_result_attributes,TestRankSums.test_ranksums_result_attributes  sZ     ~~dffdff*577=v 	!!$&&$&&.9;;A6 	#rz   c                 r    [         R                  " U R                  U R                  5      n[	        US5        g )Nr  )ri   r-
  rp   rq   r   rn   r   s     rw   test_ranksums_named_results(TestRankSums.test_ranksums_named_results  s%    nnTVVTVV,C!89rz   c                     [        [        SS9   [        R                  " U R                  U R
                  SS9  S S S 5        g ! , (       d  f       g = f)Nz`alternative` must be 'less'r   r   r  )r   r   ri   r-
  rp   rq   rh  s    rw   r  "TestRankSums.test_input_validation  s2    :-KLNN466466x@ MLLs   +A
Ar   N)r   r   r   r   r   r  rn  r|  rp   rq   rP  r  r  r/
  r3
  r  r   r   rz   rw   r*
  r*
    sZ    IINN199>>!R DAq[[],LM$ N$:Arz   r*
  c                   z    \ rS rSrS r\" SS9\R                  R                  S5      S 5       5       r	S r
S rS	rg
)TestJarqueBerai  c                     / SQnUR                  U5      nUR                  SS/5      n[        R                  " U5      n[        UR                  US   5        [        UR
                  US   5        g )N)g8MK~Ŀg/?g6r=TgGg!J_l gq"?gPHK?r   r   )rf   ri   jarque_berar/   r*  r)  )rn   ro   rp   r  r   s        rw   test_jarque_bera_against_R)TestJarqueBera.test_jarque_bera_against_R  s^    
;JJqMjj*O<="s1v.

CF+rz   Tr$  rH   c                 t   [         R                  R                  S5        [         R                  R                  SSS5      n[        R
                  " [        U5      5      =nu  p4[        R
                  " [        U5      5      =nu  pg[        R
                  " UR                  SS5      5      =nu  pX6s=:X  a:  U	s=:X  a3  UR                  s=:X  a"  UR                  s=:X  a  UR                  :X  d   e   eXGs=:X  a:  U
s=:X  a3  UR                  s=:X  a"  UR                  s=:X  a  UR                  :X  d   e   eg )Nr  r   r   rZ  r1   P  )r   r  rn  r  ri   r:
  r&  tuplerk   r*  r)  )rn   rp   jb_test1JB1r  jb_test2JB2r	  jb_test3JB3r	  s              rw   test_jarque_bera_array_like*TestJarqueBera.test_jarque_bera_array_like  s     			y!IIQ6*"..tAw7773"..uQx8873"..qyyE/BCC73bSbH$6$6b(:L:LbPXPbPbbbbbbV2VVHOOVxVVVVVrz   c                    UR                  / 5      n[        U5      (       a  [        R                  " [        [
        S9   [        R                  " U5      nS S S 5        UR                  UR                  5      n[        WR                  U5        [        UR                  U5        g Sn[        R                  " [        US9   [        R                  " U5      nS S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nr   z%At least one observation is required.)rf   r+   rP  rQ  r   r   ri   r:
  rm   r0   r*  r)  r   r   r
  s         rw   test_jarque_bera_size$TestJarqueBera.test_jarque_bera_size  s    JJrNB<<08MN''* O**RVV$CCMM3/CJJ,=Gz9''* :9 ON :9s   C!C2!
C/2
D c                 l   [         R                  R                  SS9nUR                  UR                  SS95      n[        R
                  " US S9n[        R
                  " UR                  US5      5      n[        UR                  UR                  5        [        UR                  UR                  5        [        R
                  " USS9n[        R
                  " USS S 24   5      u  pg[        R
                  " USS S 24   5      u  p[        UR                  UR                  Xh/5      5        [        UR                  UR                  Xy/5      5        [        R
                  " UR                  SS9n
[        UR                  U
R                  5        [        UR                  U
R                  5        g )	NiKr  )r1   r  r  rV   r  r   r   )r   r  r  rf   ri   r:
  rk   r0   r*  r)  r/   r  )rn   ro   r  rp   r   r  s0r  s1r  resTs              rw   r  TestJarqueBera.test_axis  s5   ii###3JJszzwz/0-

1e 45s}}5

CJJ/*""1QT7+""1QT7+rzz2(';<

BJJx$89  1-t~~6

DKK0rz   r   N)r   r   r   r   r;
  rH   rP  r  r  rF
  rI
  r  r   r   rz   rw   r8
  r8
    sD    , d#[[/0
W 1 $
W+1rz   r8
  c                   L    \ rS rSr/ SQr/ SQrSrS rS rS r	S r
S	 rS
 rSrg)TestMannWhitneyUi  )g	U3@g^3@gt3@g]o5@gzS4@gt< 4@gM	X3@gXmCk4@gLo&3@gfɘ2@g{m;^3@ga A$|3@gMѢ_4@g#3@g19T_3@ggC2@gqR4@gKk/4@g܁3@gZ2@g_
3@g$`3@g
x4@g3#л5@g;VND1@g >H2@gr4@gyܤ2@g?4@g=bɇ3@)gpG3@gL:j0@g2@gJNnC1@gR;`(3@g+Pi,2@g6:Z2@gZ"3=2@gF	uSa	3@gXҀ2@gX3^83@g21@gJ2@gZ)E2@gU83@g50@gԆ3@gFz33@gz3@gڴ3@rZ   c                 ^   [         R                  " U R                  U R                  SS9u  p[         R                  " U R                  U R                  SS9u  p4[         R                  " U R                  U R                  SS9u  pV[         R                  " U R                  U R                  SS9u  px[	        X$5        [	        Xh5        [        X&:g  5        [	        US5        [	        US5        [	        US5        [	        US5        [        USU R                  S9  [        USU R                  S9  g )	Nr~  r  r    r  g=_A?r  glPz.?ri   r.
  rg   Yr   r   r
   r  	rn   u1r  u2r	  u3r	  u4p4s	            rw   test_mannwhitneyu_one_sided,TestMannWhitneyU.test_mannwhitneyu_one_sided  s    ##DFFDFFG##DFFDFF	J##DFFDFF	J##DFFDFFGRRRRRRB 1t?O?OPB 3AQAQRrz   c                 $   [         R                  " U R                  U R                  SS9u  p[         R                  " U R                  U R                  SS9u  p4[	        X$5        [	        US5        [	        US5        [        USU R                  S9  g )Nr|  r  rS
  r  glPz.?r  ri   r.
  rg   rU
  r   r
   r  rn   rW
  r  rX
  r	  s        rw   test_mannwhitneyu_two_sided,TestMannWhitneyU.test_mannwhitneyu_two_sided  sp    ##DFFDFFL##DFFDFFLRRRB 2(,(8(8	:rz   c                 f   [         R                  " U R                  U R                  SSS9u  p[         R                  " U R                  U R                  SSS9u  p4[         R                  " U R                  U R                  SSS9u  pV[         R                  " U R                  U R                  SSS9u  px[	        X$5        [	        Xh5        [        X&:g  5        [	        US5        [	        US5        [	        US5        [	        US5        [        USU R                  S9  [        US	U R                  S9  g )
NFr~  r  r  rS
  r  gii5?r  g22?rT
  rV
  s	            rw   &test_mannwhitneyu_no_correct_one_sided7TestMannWhitneyU.test_mannwhitneyu_no_correct_one_sided  s    ##DFFDFFE068##DFFDFFE09;##DFFDFFE09;##DFFDFFE068 	RRRRRRB 1t?O?OPB 4$BRBRSrz   c                 (   [         R                  " U R                  U R                  SSS9u  p[         R                  " U R                  U R                  SSS9u  p4[	        X$5        [	        US5        [	        US5        [        USU R                  S9  g )NFr|  r  rS
  r  g22?r  r_
  r`
  s        rw   &test_mannwhitneyu_no_correct_two_sided7TestMannWhitneyU.test_mannwhitneyu_no_correct_two_sided-  s|    ##DFFDFFE0;=##DFFDFFE0;= 	RRRB 4(,(8(8	:rz   c                    [         R                  " / SQ5      n[         R                  " / SQ5      n[        [        R                  " XSS9S5        [        [        R                  " XSS9S5        [        [        R                  " XSS9S	5        g )
N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rm  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rm  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rm  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rm  r   r   r   r   rm  r   r   rm  r   r   rm  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rm  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rm  r   r   r   r   r   r   r   r   r   rm  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r1  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   rm  r   rm  r   r   r   r   rm  r   r   r   rm  r   r   r   r   r   rm  r   r   r1  r   r   r   r   r   r   r   r   r   r   rm  r   rm  r   r   r   r   r   r   rm  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rm  r   r   r   r   r   rm  rm  r   r   rm  r   r   rm  r   rm  r   r   r   r   rm  rm  r   r   r   r   r   r   r   r   r   r   r   r   r   r   rm  r   r   r   r   r   rm  rm  rm  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rm  r   r   rm  r   r   r   r   rm  r   r   r   r   r   r   r   r   r   r   r   r   rm  r   r   r   rm  r   r   r   r   r   r   r~  r  )     @g ?չ>r  )rj
  g&)E?r|  )rj
  g?չ?)r   r   r   ri   r.
  rp  s      rw   test_mannwhitneyu_ones'TestMannWhitneyU.test_mannwhitneyu_ones9  s|    HH . /& HH & ' 	**1VD:	< 	**1YG2	4**1[I5	7rz   c                 r    Sn[         R                  " U R                  U R                  SS9n[	        X!5        g )Nr  r~  r  )ri   r.
  rg   rU
  r   r  s      rw   #test_mannwhitneyu_result_attributes4TestMannWhitneyU.test_mannwhitneyu_result_attributesd  s+    ,
  VDC,rz   r   N)r   r   r   r   rg   rU
  r  r\
  ra
  rd
  rg
  rk
  rn
  r   r   rz   rw   rQ
  rQ
    s9    	-A	NA KS :T(
:)7V-rz   rQ
  c                      / SQn / SQn[        [        R                  " X5      S   SS5        Sn[        R                  " X5      n[        X25        [	        UR
                  UR                  5        g )N)"r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )"g-@g+@g(@ri  r  r  g333333@ffffff@g333333@r=   r  皙	@r1  r  r  r<   rs  ffffff@ @333333?ru
  r;   ?rv
  rm  rm  r  rD  r2  rk  r:   r  r  r1  r   g/"?r4   r'  )r   ri   pointbiserialrr   r   r(  r*  )rp   rq   r,  r   s       rw   test_pointbiserialrx
  k  s_    	A	&A ,,Q215wB +J


q
$C(#--0rz   c                     [         R                  " / SQ5      n [        R                  " U 5      n/ SQn[	        US   U5        [         R                  " / SQ5      n[        R                  " U5      n[         R                  " / SQ5      n[	        US   U5        [        R                  " X5      u  pV[        XQS   5        [        XdS   5        [        R                  " XU 5      u  pVn[        XQS   5        [        XdS   5        [        XqS   5        [         R                  " S5      n [         R                  " / SQ/ SQ/5      n[        [        R                  " U S	U -  5      US
S9  [        SS5      n	[         R                  " / SQ5      n
[         R                  " X5      n[         R                  " / SQ5      n[         R                  " X5      n[        R                  " U5      n[        US   USS9  g )N)r   r1   r3   )r6   rQ  r6   r   )r   r2   r5   r8   )r  r   r   r  r4   )㪪@I?g&>ڿr{
  rz
  )5@㪪@gIr}
  r|
  r1   r7   rS  r]   )r4   r]   r8   r2   r1   r1   )g_v	@g1%?g"u?gZӼ?g!u @gq&@r3   )
r   r   ri   obrientransformr   r   r   r   r  repeat)r  re  r  r  rf  r9  rE  rY  r  valuesrepsr  transformed_valuess                rw   test_obrientransformr
  |  s   	)	B			r	"BHBqE8$	,	B			r	"Bxx'HBqE8$   (DAqEqE ##BB/GA!qEqEqE 
1BXXDFHIF e33B"=vqQ 1b\F88'(D99V"D #< =yy+2H""4(FfQi1=rz   r  )rW   rX  r  weightsc                    U=(       d    U R                   n[        U5      S:X  a  Uu  pxOUu  pynU R                  XsS9nU R                  XS9nUb  U R                  XSS9OUn[        U5      S:X  a  U4OUW	4nU" XbX5S.6n
[        XUS9  g )Nr1   rZ  )rW   rX  r
  r  )r   r  rf   r/   )ro   mean_funrW   rX  r  r
  r0  
array_liker  rT  rp   s              rw   check_equal_xmeanr
    s     RZZE
4yA~"
G!%
wJ4Jjjj.G292Ebjjj.7GINJ=QD$@AAT*rz   c                  8    [        U S[        R                  0UD6$ Nr
  )r
  ri   r  r0  r1  s     rw   check_equal_gmeanr
        dCU[[CFCCrz   c                  8    [        U S[        R                  0UD6$ r
  )r
  ri   hmeanr
  s     rw   check_equal_hmeanr
    r
  rz   c                  8    [        U S[        R                  0UD6$ r
  )r
  ri   pmeanr
  s     rw   check_equal_pmeanr
    r
  rz   c                   8   \ rS rSrS rS rS r\" SSS9\R                  R                  S5      S	 5       5       rS
 rS rS rS rS r\R                  R                  SSS9\R                  R                  S5      S 5       5       rS rS rS r\S 5       rSrg)	TestHMeani  c                 $    / SQnSn[        X#US9  g N)r   r   r1   r   r  r
  rn   ro   r9  r  s       rw   test_0TestHMean.test_0      !,rz   c                 D    / SQnSn[        X#US9  / SQnSn[        X#US9  g )NrK  g=b#A@r  r  gQ?r
  r
  s       rw   test_1dTestHMean.test_1d  s*    5!,:!,rz   c                 N    [         R                  " SS/5      nSn[        X#USS9  g )Nr   r   r   ro   r  r   r   r
  r
  s       rw   test_1d_with_zeroTestHMean.test_1d_with_zero  s%    HHaV!#6rz   rG   ``array_api_strict.where` `fillvalue` doesn't accept Python scalars. See data-apis/array-api#807.rE   rH   c                     [         R                  " / SQ5      nSn[        R                  " [        US9   [        X!R                  USS9  S S S 5        g ! , (       d  f       g = f)Nr   r   rb   z$The harmonic mean is only defined...r   r   r
  )r   r   rP  rQ  r   r
  rm   )rn   ro   r9  r  s       rw   test_1d_with_negative_value%TestHMean.test_1d_with_negative_value  sA     HHZ 8\\.8aBS9 988s   A
A!c                 Z    / SQ/ SQ/ SQ/nSn[        [        R                  " U5      X1S9  g )Nr\   r  r  r  r   r9  rL  r=  r  r  rS  x   gmWUC@r  )r
  r   r   r
  s       rw   test_2dTestHMean.test_2d  s'    /1DE"((1+w6rz   c                 `    / SQ/ SQ/ SQ/n[         R                  " / SQ5      n[        X#SUS9  g )Nr
  r
  r
  )U|ϊ6@g4.=C@JQ6LsJ@E]P@r   rW   ro   r
  r
  s       rw   test_2d_axis0TestHMean.test_2d_axis0  s+    /1DE((OP!14rz   c                 `    / SQ/ SQ/ SQ/n[         R                  " / SQ5      n[        X#SUS9  g )Nr\   r   r  r  r
  r
  )r
  r   r
  r
  r   r
  r
  r
  s       rw   test_2d_axis0_with_zero!TestHMean.test_2d_axis0_with_zero  s+    .0CD((GH!14rz   c                 `    / SQ/ SQ/ SQ/n[         R                  " / SQ5      n[        X#SUS9  g )Nr
  r
  r
  )g3333333@O@y@Y@r   r
  r
  r
  s       rw   test_2d_axis1TestHMean.test_2d_axis1  s+    /1DE((<=!14rz   c                 `    / SQ/ SQ/ SQ/n[         R                  " / SQ5      n[        X#SUS9  g )Nr
  r
  r
  )r   r
  r
  r   r
  r
  r
  s       rw   test_2d_axis1_with_zero!TestHMean.test_2d_axis1_with_zero  s+    .0CD((;<!14rz   T,array-likes only supported for NumPy backendr   c                 ~    / SQn/ SQnSn[         R                  " X#S9n[        U[        R                  " U5      SS9  g )Nr1   r\   r5   r\   r4   r2   r1  r
  h㈵>r  )ri   r
  r/   r   rf   rn   ro   r9  r
  r  r   s         rw   test_weights_1d_listTestHMean.test_weights_1d_list  s8      kk!-RZZ0t<rz   c                     [         R                  " / SQ5      n[         R                  " / SQ5      nSn[        X$USUS9  g )Nr
  r
  r2   r
  r
  r  ro   )r   rf   r
  rn   ro   r9  r
  r  s        rw   test_weights_1dTestHMean.test_weights_1d  s3     JJz"**Z(!gDRHrz   c           	          [         R                  " SS/SS/SS//5      n[         R                  " SS/SS/SS//5      n[         R                  " SS/5      n[        X$SUSUS	9  g )
Nr1   r4   r\   r5   r   r2   r   r
  rW   r
  r  ro   r
  r
  s        rw   test_weights_2d_axis0TestHMean.test_weights_2d_axis0  sh     HHq!fr1g1v./((RGaVaV45((Aq6"!1gDRPrz   c           	          [         R                  " / SQ/ SQ/5      n[         R                  " / SQ/ SQ/5      n[         R                  " SS/5      n[        X$SUSUS	9  g )
Nr
  r6   r6   r6   r
  r  r2   r6   r   r
  r
  r
  r
  s        rw   test_weights_2d_axis1TestHMean.test_weights_2d_axis1"  sL     HHj),-((J	23((Aq6"!1gDRPrz   c           	          [         R                  " / SQ5      n[         R                  R                  / SQ/ SQS9nSn[         R                  n[        X$US[         R                  US9  g )Nr1   r\   r5   rm  r\   r4   r2   rm  r   r   r   r   r  r2   r
  r
  r  rX  ro   )r   r   rc  r
  r   r
  s        rw   test_weights_masked_1d_array&TestHMean.test_weights_masked_1d_array*  sM     HH^$%%++n<+@UU!gD "

r	3rz   r   N)r   r   r   r   r
  r
  r
  rH   rP  r  r  r
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r(   r
  r   r   rz   rw   r
  r
    s    -
-7
 (UW [[/0: 1W:755
55
 [[!!= "  [[/0
= 1	

=IQQ 3 3rz   r
  c                       \ rS rSrS rS rS rS rS rS r	S r
S	 r\R                  R                  S
SS9\R                  R                  S5      S 5       5       rS r\S 5       rSrg)	TestGMeani6  c                 $    / SQnSn[        X#US9  g r
  r
  r
  s       rw   r
  TestGMean.test_08  r
  rz   c                     / SQnSn[        X#US9  / SQn[        SS5      n[        X#SUS9  [        / SQ[        5      n[        SS5      n[        X#UR                  US	9  g )
NrK  gsŤF@r  r  r~  rp  rX  r  ro   )rX  ro   )r
  r   r   r   r
  s       rw   r
  TestGMean.test_1d=  s[    5!,w/!5R8,(w/!BJJ2>rz   c                 2    / SQ/ SQ/ SQ/nSn[        X#US9  g )Nr
  r
  r
  g/,$qJ@r  r
  r
  s       rw   r
  TestGMean.test_2dL  s    /1DE!,rz   c                     / SQ/ SQ/ SQ/n[         R                  " / SQ5      n[        X#SUS9  [        / SQ/ SQ/ SQ/5      n[        / SQ5      n[        X#SSUS	9  g )
Nr
  r
  r
  )g4@A@g5H@g`8|wЭN@gm~&+R@r   r
  r  rX  rW   r  ro   r   r   r
  r
  s       rw   r
  TestGMean.test_2d_axis0R  sT    /1DE((NO!14<|<=%!15R@rz   c                     / SQ/ SQ/ SQ/n[         R                  " / SQ5      n[        X#SUS9  [        / SQ/ SQ/ SQ/5      n[        SS	5      n[        XDU/5      n[        X#SS
US9  g )Nr
  r
  r
  )gD" 6"6@gcP@g
ҧZ@r   r
  r  r~  rp  rX  r
  )r   r   r
  r   )rn   ro   r9  r  r  s        rw   r
  TestGMean.test_2d_axis1\  sd    /1DE((CD!14<|<=-)q	"!15R@rz   c                 8    [        / SQ5      nSn[        X#SUS9  g )N)g}Ô%ITri  gu <7~ri  r  r
  )r   r
  r
  s       rw   test_large_valuesTestGMean.test_large_valuesg  s    '(!5R8rz   c                     / SQnSn[         R                  " SS9   [        X#US9  S S S 5        g ! , (       d  f       g = f)N)
r\   r  r  r  r   r9  rL  r=  r  r   r   r}  r	  r  )r   r  r
  r
  s       rw   test_1d_with_0TestGMean.test_1d_with_0l  s.    3[[X&aR0 '&&s   /
=c                     / SQn[         R                  n[         R                  " SS9   [        X#US9  S S S 5        g ! , (       d  f       g = f)N)
r\   r  r  r  r   r9  rL  r=  r  rb   r}  r~  r  )r   rm   r  r
  r
  s       rw   test_1d_negTestGMean.test_1d_negs  s2    4&&[[*aR0 +**s	   =
ATr
  r   rH   c                 ~    / SQn/ SQnSn[         R                  " X#S9n[        U[        R                  " U5      SS9  g )Nr  r1   r4   r5   r3   r2   GZ*oG8@r
  r
  r  )ri   r  r/   r   rf   r
  s         rw   r
  TestGMean.test_weights_1d_listz  s8     !
 kk!-RZZ0t<rz   c                     [         R                  " / SQ5      n[         R                  " / SQ5      nSn[        X$USUS9  g )Nr  r
  r
  r
  r
  r
  r
  s        rw   r
  TestGMean.test_weights_1d  s3     HH_%((?+!gDRHrz   c           	          [         R                  " / SQ5      n[         R                  R                  / SQ/ SQS9nSn[         R                  n[        X$US[         R                  US9  g )Nr  )r1   r4   r5   r3   r2   r4   )r   r   r   r   r   r   r  r
  r
  r
  )r   r   rc  r
  r   r
  s        rw   r
  &TestGMean.test_weights_masked_1d_array  sP     HH'(%%++07I+JUU!gD "

r	3rz   r   N)r   r   r   r   r
  r
  r
  r
  r
  r
  r
  r
  rP  r  rH   r  r
  r
  r(   r
  r   r   rz   rw   r
  r
  6  s    -
?-A	A9
11 [[!!= "  [[/0= 1	
=I 3 3rz   r
  c            
          \ rS rSrS rS rS rS rS r\	" SSS	9\
R                  R                  S
5      S 5       5       r\
R                  R                  SSS/SS/SS//S4\R                   " SS/SS/SS//5      S4/5      S 5       r\
R                  R                  S/ SQ/ SQ/ SQ/S4/ SQ/ SQ/ SQ/S4/5      S 5       r\
R                  R                  S/ SQ/ SQ/ SQ/S4/ SQ/ SQ/ SQ/S4/5      S 5       rS r\
R                  R                  SSS9\
R                  R                  S
5      S  5       5       r\S! 5       r\
R                  R                  S"/ S#Q5      S$ 5       rS%rg&)'	TestPMeani  c                 X    [         R                  " X-  5      U R                  -  SU-  -  $ r  )r   rM  r  r9  rT  s     rw   pmean_referenceTestPMean.pmean_reference  s$    qtqvv%1--rz   c                 r    [         R                  " X U-  -  5      [         R                  " U5      -  SU-  -  $ r  )r   rM  )r9  rT  r
  s      rw   wpmean_referenceTestPMean.wpmean_reference  s-    wA~&8AaC@@rz   c                    [         R                  " [        SS9   [        R                  " UR                  / SQ5      UR                  S/5      5        S S S 5        [         R                  " [        SS9   [        R                  " UR                  / SQ5      UR                  S/5      5        S S S 5        g ! , (       d  f       Ni= f! , (       d  f       g = f)NzPower mean only defined forr   r  r   )rP  r   r   ri   r
  rf   r  s     rw   test_bad_exponentTestPMean.test_bad_exponent  s    ]]:-JKKK

9-rzz1#? L]]:-JKKK

9-rzz1#? LK LKKKs   9B649C6
C
Cc                 2   / SQSp2[         R                  [        R                  " U5      U5      n[	        X#XAS9  / SQSp2[         R                  [        R                  " U5      U5      n[	        X#XAS9  / SQSp2[        R
                  " S5      n[	        X#XAS9  g )NrK  r=   r  g      r  r1   rA   )r  r  r   r   r
  r6  rn   ro   r9  rT  r  s        rw   r
  TestPMean.test_1d  sx    8#1++BHHQK;!/8$1++BHHQK;!/Q1''9:!/rz   c                 R    [         R                  " SS/5      Sp2Sn[        X#USUS9  g )Nr   r   rb   r   r
  )r   r   r
  r  s        rw   r
  TestPMean.test_1d_with_zero  s)    xxA1!cb9rz   rG   r
  rE   rH   c                     [         R                  " / SQ5      Sp2Sn[        R                  " [        US9   [        X#UR                  US9  S S S 5        g ! , (       d  f       g = f)Nr
  Gz?z!The power mean is only defined...r   r  )r   r   rP  rQ  r   r
  rm   )rn   ro   r9  rT  r  s        rw   r
  %TestPMean.test_1d_with_negative_value  sC    
 xx
#T15\\.8aBFFr2 988s   A
A"r  r\   r  r   r9  r  r  ro  r:   c                 l    [         R                  [        R                  " U5      U5      n[	        XXCS9  g )Nr  r  r  r   r   r
  )rn   r9  rT  ro   r  s        rw   test_2d_axisnoneTestPMean.test_2d_axisnone  s(     ++BHHQK;!/rz   r
  r
  r
  r
  c                 $   [        [        US   5      5       VVs/ s HU  n[        R                  [        R
                  " [        [        U5      5       Vs/ s H
  oQU   U   PM     sn5      U5      PMW     nnn[        XUSUS9  g s  snf s  snnf )Nr   r
  )r  r  r  r  r   r   r
  )rn   r9  rT  ro   r  r  r  s          rw   r
  TestPMean.test_2d_axis0  s     3qt9%	
 & %%5Q=9=aA$q'=9:A &	 	 
 	!aB7	 :
s   ;BB'BBc                     U Vs/ s H-  n[         R                  [        R                  " U5      U5      PM/     nn[	        XUSUS9  g s  snf )Nr   r
  r  )rn   r9  rT  ro   a_r  s         rw   r
  TestPMean.test_2d_axis1  sC     IJJ"9,,RXXb\1=J!aB7 Ks   4Ac           	          / SQSp2/ SQn[         R                  [        R                  " U5      X45      n[	        X#XTSUS9  g )Nr
  ރBr
  r
  r
  )r  r	  r   r   r
  rn   ro   r9  rT  r
  r  s         rw   r
  TestPMean.test_weights_1d  s6    ;1,,RXXa[!E!tKrz   Tr
  r   c                     / SQSp2/ SQn[         R                  [        R                  " U5      X45      n[        R
                  " X#US9n[        U[        R                  " U5      SS9  g )Nr
  r   r
  r
  r
  r  )r  r	  r   r   ri   r
  r/   rf   )rn   ro   r9  rT  r
  r  r   s          rw   r
  TestPMean.test_weights_1d_list  sQ     ;1,,RXXa[!E kk!0RZZ0t<rz   c           
          [         R                  " / SQ5      Sp2[         R                  R                  / SQ/ SQS9n[         R                  " X$S9n[         R                  n[	        X#XTS[         R
                  US9  g )	Nr
  r   r
  r
  r  r
  r
  r
  )r   r   rc  averager
  r   r!  s         rw   r
  &TestPMean.test_weights_masked_1d_array   sV    xx'1%%++n<+@**Q0UU!t "

r	3rz   )rW   fun_namerT  ))Nr	  g3E#@)r   r  r   )r   r
  rb   c           
         ^ US:X  a  U4S jnO[        [        U5      n[        R                  " SS/SS/SS//5      n[        R                  " SS/SS/SS//5      nU" XaUS	9n[	        UTXUS
US9  g )Nr	  c                 2   > [         R                  U TU5      $ r  )r  r	  )r9  rW   r
  rT  s      rw   fun&TestPMean.test_weights_2d.<locals>.fun  s     11!Q@@rz   r1   r4   r\   r5   r   r2   )rW   r
  r
  r
  )r[  ri   r   r   r
  )	rn   rW   r(  rT  ro   r+  r9  r
  r  s	      `     rw   test_weights_2dTestPMean.test_weights_2d	  s     ))A %*CHHq!fr1g1v./((RGaVaV45aG4!QG$SUVrz   r   N)r   r   r   r   r  r	  r  r
  r
  rH   rP  r  r  r
  r  r   r   r  r
  r
  r
  r
  r(   r
  r-  r   r   rz   rw   r  r    s   .A@0:
 (TV [[/03 1V3 [[8b"XCy
)4	0
((RHr2hS	2
3S	9	;
0
0 [[-/B
CT	J,.A
BC	H	J
8
8 [[-/B
CT	J,.A
BC	H	J
8
8L [[!!= "  [[/0= 1	
= 3 3 [[!		W	Wrz   r  c                      \ rS rSr\R
                  " S5      S-   rSr\R                  SSS5      r	S r
S	 rS
 r\R                  R                  SSS\R                   \R"                  45      S 5       rS rS rS rS rS rS rS rS rSrg)TestGSTDi  r~  r   gv aZ@r1   r2   r3   c                 n    [         R                  " U R                  5      n[        XR                  5        g r  )ri   r  array_1dr   gstd_array_1drn   gstd_actuals     rw   test_1d_arrayTestGSTD.test_1d_array!  s"    jj/%7%78rz   c                     [         R                  " [        U R                  5      5      n[	        XR
                  5        g r  )ri   r  r?
  r2  r   r3  r4  s     rw    test_1d_numeric_array_like_input)TestGSTD.test_1d_numeric_array_like_input%  s'    jjt}}!56%7%78rz   c                     [         R                  " [        SS9   [        R                  " S5        S S S 5        g ! , (       d  f       g = f)Nzufunc 'log' not supportedr   z*You cannot take the logarithm of a string.)rP  r   r'  ri   r  rh  s    rw   )test_raises_value_error_non_numeric_input2TestGSTD.test_raises_value_error_non_numeric_input)  s+    ]]9,GHJJCD IHHs	   :
A	bad_valuer   rb   c                 v   [         R                  " U R                  U/5      n[         R                  " U5      (       a;  Sn[        R
                  " [        US9   [        R                  " U5      nS S S 5        O[        R                  " U5      n[        W[         R                  5        g ! , (       d  f       N)= f)Nz3The geometric standard deviation is only defined...r   )r   r6  r2  rf  rP  rQ  r   ri   r  r   rm   )rn   r>  rp   r  r   s        rw   test_returns_nan_invalid_value'TestGSTD.test_returns_nan_invalid_value.  su    IIdmmi[1;;y!!KGnG<jjm =< **Q-CS"&&!	 =<s   B**
B8c                     [        / SQ[        R                  SSS//5      n[        R                  " USS9n[        U[        R                   " S[        R                  /5      5        g )N)r   r   r   r   r   r1   r2   rV   r3   )r   r   rm   ri   r  r   )rn   r9  r5  s      rw   test_propagates_nan_values#TestGSTD.test_propagates_nan_values9  sI    =2661a"345jj+RXXq"&&k%:;rz   c                     [         R                  " [        SS9   [        [        R
                  " U R                  U R                  R                  S9[        R                  5        S S S 5        g ! , (       d  f       g = f)NzDegrees of freedom <= 0r   rM  )
rP  rQ  r   r   ri   r  r2  r  r   r  rh  s    rw   )test_ddof_equal_to_number_of_observations2TestGSTD.test_ddof_equal_to_number_of_observations>  sE    \\.0IJDMM8J8JKRVVT KJJs   AA//
A=c                 l    [         R                  " U R                  S S9n[        XR                  5        g r)	  )ri   r  array_3dr   r3  r4  s     rw   test_3d_arrayTestGSTD.test_3d_arrayB  s$    jjT:%7%78rz   c                 ^    [         R                  " U R                  SS9n[        USS/5        g )Nr"  rV   g~d@g<
?)ri   r  rI  r   r4  s     rw   test_3d_array_axis_type_tuple&TestGSTD.test_3d_array_axis_type_tupleF  s%    jjU;j*%=>rz   c                     [         R                  " U R                  SS9n[        R                  " / SQ/ SQ/ SQ/5      n[        X5        g )Nr   rV   )gĶ?@gQӫ@g֌@gן7R@)g%Ȁ@ge@gv6B5 @g _?)gE ?gީ?gk̊Y?g%:?ri   r  rI  r   r   r   rn   r5  gstd_desireds      rw   test_3d_array_axis_0TestGSTD.test_3d_array_axis_0J  s<    jjQ7xxOOO!
 
 	2rz   c                     [         R                  " U R                  SS9n[        R                  " / SQ/ SQ/5      n[        X5        g )Nr   rV   )gN@g85@g'ĥ?gwth?)gHnaX?gG?gBu?gE?rP  rQ  s      rw   test_3d_array_axis_1TestGSTD.test_3d_array_axis_1S  s9    jjQ7xxLL!
  	2rz   c                     [         R                  " U R                  SS9n[        R                  " / SQ/ SQ/5      n[        X5        g )Nr1   rV   )gt80?gі?g?)gۘ]~?gmT6(?g	G?rP  rQ  s      rw   test_3d_array_axis_2TestGSTD.test_3d_array_axis_2[  s9    jjQ7xx??!
  	2rz   c                    [         R                  R                  U R                  S:  U R                  5      nSn[        R
                  " [        US9   [        R                  " USS9nS S S 5        [        R                  " U R                  SS9n/ SQ/ SQ/n[        WU5        [        UR                  U5        g ! , (       d  f       NX= f)Nr   z:`gstd` support for masked array input was deprecated in...r   r1   rV   rq  r  )r   rc  masked_whererI  rP  rQ  r  ri   r  r   r   r  )rn   rc  r  r5  rR  r  s         rw   test_masked_3d_arrayTestGSTD.test_masked_3d_arrayc  s    UU 2DMMBN\\,G<**Ra0K =zz$--a89%\2[%%t, =<s   B;;
C	r   N)r   r   r   r   r   r   r2  r3  rk   rI  r6  r9  r<  rP  r  r  r  rm   r@  rC  rF  rJ  rM  rS  rV  rY  r]  r   r   rz   rw   r0  r0    s    yy#a'H"M1a(H99E
 [[[1b"&&"&&*AB" C"<
U9?333-rz   r0  c            	         [         R                  " [         R                  " SSS5      [         R                  " SSS5      [         R                  " SSS5      45      n SnS	n/ S
Qn[        X5       H3  u  pE[	        [
        R                  " X!U5      R                  USSU 3S9  M5     [	        [
        R                  " SSS5      R                  SSS9  g )Nr1  r  r4   r  g?r  ffffff?r  i  )r   r   gs  gG|G{g	ɺM>6g>
ztt+g#ӌRM/gF׸fz2gU8u5g8M8gФ)Ba?g%վ?g*+a5?gś?gڒJ|>r^   z
fail forp=)r  err_msgr   r  gVݶ3;r  )r   re  r!  r   r
   ri   	binomtestr)  )ppr  rp   rf  rT  r   s         rw   test_binomtestrd  n  s    	S#q1T43T435 
6B 	AA(G b"EOOA!4;;S(*j4D	F # C5<</$&(rz   c                     SS// SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ S	Q/ S
Q/
n [        SS5       HP  n[        US-   5       Vs/ s H$  n[        R                  " X!S5      R                  PM&     nn[	        X0US-
     SS9  MR     g s  snf )Nr   )r:   r   r:   )rp  r   r   rp  )r  r  r   r  r  )r!        ?r   r   rf  r!  )r"        ?      ?r   rh  rg  r"  )r  r        ?r   r   ri  r  r  )	      ?      ?     ?     @?r   rm  rl  rk  rj  )
      p?      ?      ?     @?r   r   rq  rp  ro  rn  )      `?      ?      ?      ?      ?r   rv  ru  rt  rs  rr  r   r]   r:   r\   rS  )r  ri   rb  r)  r   )r  r~  r  r  s       rw   test_binomtest2rw    s     
c
 +8G		*	E	D" 1b\;@Q<H<ac*11<HDqs)R8 Hs    +Bc                  "   [        SS5       V Vs/ s H>  n [        SS5        H*  n[        R                  " X U-  SU-  5      R                  PM,     M@     nn n[	        U[
        R                  " [        U5      [        5      5        [
        R                  " / SQ5      n[
        R                  " / SQ5      n[        SS5       V Vs/ s HA  n [        SS5        H-  n[        R                  " U S-   X-  SU-  5      R                  PM/     MC     nn n[        SS5       V Vs/ s HA  n [        SS5        H-  n[        R                  " U S-
  X-  SU-  5      R                  PM/     MC     nn n[        XTSS9  [        XcSS9  g s  snn f s  snn f s  snn f )	Nr   r]   r1   r   )Zr:   grq?g     ?glq?gx0f#?g%d)MO?g   	o?g6?g:X@?r  gsw?g    ?gR'jMV?gEf?gF5a?gAQU?g'W?gk?rh  g
ņB?g  ?g$?g{dU'?gD:B?gwV?gR0Nf?gOq?rm  g[k^?g T+?gO?gggh(?gP-@?gOQ?g}^?gV7_i?rv  ge$?gр?g#>?g5z@?g:?gf?gzP?g  ?     ?gg*),?g}A_?g}aA?gH]@_?g
y7s?gPG?g>)\R?gjc6?K?go; ,?g!O0?g?g}e?g5?g?!A^?gN/#?g*?    @?g?g?g3?g.1?gdT\1-?gt0W59?goQC?gX4J?   ?g
?gf?C"?g\6I?g4b?g|$or?gWNS~?gT?gXnc?   \?gY\?gp ^a?gX-K?g#c?g
3?g75Q?gMJ[?gP8R?)Zr:   gw	%?g     ?gS g?gv^?g*uCi?g  a?g]?gE9Q?r  g/?g     ?g	x&~?g#?g5B?g	A'9?gpZ?gWV$u?rh  gqIb?g  @N?g1Y?g5?gO?gc-?gk?g )?rm  glMV?g?$?gT*r?gCqRv?grx?gωZ?gExY?g<T ?rv  gJ9Ͻd?g `Ԗt?gT?gEz?gQ?g7C<*?g<?g~ K?ry  g8?g~ȍEt?g⿒?g<v?gHE:?g8Z$?gbº5?gvC?rz  g`Yw?gA?$??gE=?g4?g3?g{G9?gp?gH ?r{  gz6f?g¯F?g(+?g	$V?gq^ws?g!?gXNJ?gK?r|  g4P?g<q?gdV;?gy?g$w?gU<vO?gMX?g	șz*?r}  giqSp?gMM?g0V$)?g]
yi/Q?gl?gl?g3Ȇ?gѾ_c?r_   rS  )r  ri   rb  r)  r   r   r  r  r%  r   r   )r  r~  r  binom_testm1binom_testp1res4_p1res4_m1s          rw   test_binomtest3r    so    1b\9!5B<a OOAsBqD)00+7 1! 	 9rwws4y#./ 88 
 LP 88 
 L@ a<$1eArl qsACA.55.: 6$  < a<$1eArl qsACA.55.: 6$  < r:r:q9d<<s   AE?AFAFc                   &    \ rS rSrS rS rS rSrg)TestTrimi  c           
      \   [         R                  " S5      n[        [         R                  " [        R
                  " US5      5      [         R                  " S5      5        [        [         R                  " [        R
                  " US5      5      [         R                  " S5      5        [        [         R                  " [        R
                  " USSS95      [         R                  " SS5      5        [        [         R                  " [        R
                  " US	SS95      [         R                  " S
S5      5        [        [        R
                  " US5      / 5        [        [        R
                  " USSS9/ 5        [        [        R
                  " / S5      / 5        [        [        R
                  " / S	SS9/ 5        [        [        R
                  " / S5      / 5        [         R                  " S5      R                  SS5      n[         R                  " SS5      R                  SS5      nSn[        R
                  " USSUS9n[        [         R                  " XCS9U5        Sn[        R
                  " UR                  SSUS9n[        [         R                  " XCS9UR                  5        g )Nr]   r1  r\   r  r8   left)tailr1   tE]t?r2   r   r5  r~  r5   r3   r4   r   )r  rW   rV   r   )r   r   r   sortri   trim1rk   r  )rn   r9  r  rW   trimmeds        rw   
test_trim1TestTrim.test_trim1  s   IIbMRWWU[[C01299R=ARWWU[[C01299Q<@RWWU[[Cf=>YYq"%	'RWWU[[E?@YYq"%	'U[[C("-U[[Cf5r: 	U[[S)2.U[[U8"=U[[T*B/ IIbM!!!Q'ii2&&q!,++a6=RWWW0#6++acc3V$?RWWW0#%%8rz   c           
         [         R                  " S5      n[        [         R                  " [        R
                  " US5      5      [         R                  " SS5      5        [        [         R                  " [        R
                  " US5      5      [         R                  " / SQ5      5        [        [         R                  " [        R
                  " [         R                  " S5      R                  SS	5      S5      5      [         R                  " S	S
5      R                  S	S	5      5        [        [         R                  " [        R
                  " [         R                  " S5      R                  S	S5      R                  S5      5      [         R                  " / SQ/ SQ/5      5        [        [        [        R
                  [         R                  " S5      R                  S	S5      R                  S5        [        [        R
                  " / S5      / 5        [        [        R
                  " / S5      / 5        [        [        R
                  " / S5      / 5        g )Nr]   r  r2   r7   r  )r1   r2   r3   r4   r5   r6   r7   r~  r5   r3   r  rD  )r1   r7   rZ   r  )r2   r8   r  rY   r5  r1  )r   r   r   r  ri   trimbothr   rk   r  r   r   )rn   r9  s     rw   test_trimbothTestTrim.test_trimboth  ss   IIbMRWWU^^Au56		!QHRWWU^^As34XX34	6RWWU^^BIIbM,A,A!Q,GMNYYq"%--a3	5RWWU^^BIIbM,A,A!Q,G,I,I,02 3XX~~>?	A 	j%..iim++Aq133T	; 	U^^B,b1U^^B.3U^^B-r2rz   c                 (   [         R                  " / SQ5      n[         R                  " / SQ5      n[         R                  " S5      R                  SS5      US S 24   n[         R                  " S5      R                  SSSS9US S 24   n[	        [
        R                  " US5      [         R                  " / S	Q5      5        [	        [
        R                  " US5      [         R                  " / S
Q5      5        [         R                  " / SQ5      n[         R                  " S5      R                  SS5      US S 24   n[	        [
        R                  " US5      [         R                  " / SQ5      5        / SQn[	        [
        R                  " US5      S5        [	        [
        R                  " / SQS5      S5        [         R                  R                  S5        [         R                  R                  SSS9nS HP  n[
        R                  " USUS9n[
        R                  " [         R                  " XS5      S5      n	[	        X5        MR     [
        R                  " USS S9n[
        R                  " UR                  5       S5      n	[	        X5        [        [        [
        R                  US5        [	        [
        R                  " / S5      [         R                  5        [	        [
        R                  " / S5      [         R                  5        g )N)r3   r7   r1   r   r8   r4   r\   r   r6   r2   r5   )r2   r4   r   r   r1   r3   r~  r5   r3   Fry  rD  )r<   rB   g      -@g     4@r  )r   r   r2   r1   )r   r   r  r  r  r  )r6   r]   r^   rY   r   r5   r  r   r4   r   r  r\   rd   r8   r  r  r  r  r1   rZ   r3   r_   r7   r2   r[   )r4   r3   r2   r   r1   r   r<   r[  r  )r4   r5   r3   r6   r  )r   r   r1   r2   rb   rV   r   rk  r   )r   r   r   rk   r   ri   	trim_meanr  rn  r\	  r3  r  r   r   rm   )
rn   r9  idxr  r  idx4a4rW   r  r  s
             rw   test_trim_meanTestTrim.test_trim_mean+  s   HH78hh)*YYr]""1a(a0YYr]""1as"3CF;U__R.XX45	7U__R.XX23	5xx%YYr]""1a(q1U__R.XX;<	>%U__Q-t4U__]D93? 			tIIb|4$D??1d6D??2;;q#:DAD$ %
 q$T2qwwy$/T j%//1c: 	U__R-rvv6U__R-rvv6rz   r   N)r   r   r   r   r  r  r  r   r   rz   rw   r  r    s    983$$7rz   r  c                   2    \ rS rSrS rS rS rS rS rSr	g)	TestSigmaClipiR  c                 "   [         R                  " [         R                  " SSS5      [         R                  " SSS5      45      nSn[        R                  " U5      u  p4n[        UR                  5       U:  5        [        UR                  5       U:  5        [        XCR                  5       X#R                  5       -  -
  5        [        XSR                  5       X#R                  5       -  -   5        [        UR                  UR                  5        g )Nr  ra      r   r  r4   r3   r   re  r!  ri   	sigmaclipr   minmaxr   rl   r   r  rn   r9  factrY  rr  upps         rw   test_sigmaclip1TestSigmaClip.test_sigmaclip1S  s    NNBKKT26Ar18MNOooa(##S&&(T%%'\12S&&(T%%'\12QVVQVV$rz   c                 <   [         R                  " [         R                  " SSS5      [         R                  " SSS5      45      nSn[        R                  " XU5      u  p4n[        UR                  5       U:  5        [        UR                  5       U:  5        [        XCR                  5       X#R                  5       -  -
  5        [        XSR                  5       X#R                  5       -  -   5        [        UR                  S5        [        UR                  S	5        g )
Nr  ra   r  r   r  r4   r;   r3   $   r  r  s         rw   test_sigmaclip2TestSigmaClip.test_sigmaclip2]  s    NNBKKT26Ar18MNOooat4##S&&(T%%'\12S&&(T%%'\12QVVQQVVR rz   c                 (   [         R                  " [         R                  " SSS5      [         R                  " SSS5      45      nSn[        R                  " XU5      u  p4n[        UR                  5       U:  5        [        UR                  5       U:  5        [        XCR                  5       X#R                  5       -  -
  5        [        XSR                  5       X#R                  5       -  -   5        [        U[         R                  " SSS5      5        g )Nr  ra   r]   r2   ?)r   re  r!  ri   r  r   r  r  r   rl   r   r  s         rw   test_sigmaclip3TestSigmaClip.test_sigmaclip3h  s    NNBKKT26KKc157 8ooat4##S&&(T%%'\12S&&(T%%'\12QCr23rz   c                     [         R                  " [         R                  " SSS5      [         R                  " SSS5      45      nSn[        R                  " XU5      nSn[        X45        g )	Nr  ra   r]   r  r  r2   r  )clippedr  r  )r   re  r!  ri   r  r   )rn   r9  r  r   r,  s        rw    test_sigmaclip_result_attributes.TestSigmaClip.test_sigmaclip_result_attributess  sV    NNBKKT26KKc157 8ooat,2
C,rz   c                 v    [         R                  " S5      n[        [        R                  " U5      S   U5        g )Nr\   r   )r   r  r   ri   r  ru  s     rw   test_std_zeroTestSigmaClip.test_std_zero{  s'    GGBKU__Q'*A.rz   r   N)
r   r   r   r   r  r  r  r  r  r   r   rz   rw   r  r  R  s    %	!	4-/rz   r  c                       \ rS rSrS r\R                  R                  SSS// 4SS/S4SS/S/4/5      S 5       rS r	S r
S	 rS
 rS rS rS rS rSrg)TestAlexanderGoverni  c                 |   / SQ/ SQ/ SQ/ SQ/nU Vs/ s H&  n[         R                  " U[         R                  S9PM(     nnU Vs/ s H&  n[         R                  " U[         R                  S9PM(     nnU Vs/ s H&  n[         R                  " U[         R                  S9PM(     nnU Vs/ s H&  n[         R                  " U[         R
                  S9PM(     nn[        R                  " U6 n[        R                  " U6 n[        R                  " U6 n	[        R                  " U6 n
UR                  UR                  s=:X  a"  U	R                  s=:X  a  U
R                  :X  d   e   eUR                  UR                  s=:X  a"  U	R                  s=:X  a  U
R                  :X  d   e   eg s  snf s  snf s  snf s  snf )N)	r_   r_   r_   r_   r_   r_   r_   r^   r^   )	rZ   r_   r^   r^   r^   r^   r^   r]   r]   )	rZ   rZ   r_   r_   r_   r_   r_   r^   r^   )	r  rZ   r_   r_   r_   r^   r^   r^   r]   rZ  )
r   rf   r  r  r&  r   ri   alexandergovernr)  r*  )rn   r0  arg
args_int16
args_int32
args_uint8args_float64	res_int16	res_int32	res_uint8res_float64s              rw   test_compare_dtypes'TestAlexanderGovern.test_compare_dtypes  s   44446 BFF#bjjBHH5
FAEF#bjjBHH5
FAEF#bjjBHH5
FEIJTc

3bjj9TJ)):6	)):6	)):6	++\:  I$4$4 7  7$/$6$67 	8 7 	8 7##y':': =##='2'<'<= 	> = 	> = GFFJs   -F*-F/9-F4,-F9r  r   r1   c                 (   [         R                  " [        [        S9   [        R
                  " U6 n[        UR                  [        R                  5        [        UR                  [        R                  5        S S S 5        g ! , (       d  f       g = fr  )rP  rQ  r   r   ri   r  r   r*  r   rm   r)  r  s      rw   test_too_small_inputs)TestAlexanderGovern.test_too_small_inputs  sU     \\,4IJ''.C/RVV, KJJr  c                 ^   [         R                  " SS9   [        R                  " SS/[         R                  [         R                  /5      nS S S 5        [        WR                  [         R                  5        [        UR                  [         R                  5        g ! , (       d  f       NW= f)Nr}  r~  r   r1   )	r   r  ri   r  r  r   r*  rm   r)  r2
  s     rw   test_bad_inputs#TestAlexanderGovern.test_bad_inputs  sc    [[*''A0@AC +S]]BFF+SZZ( +*s   8B
B,c                 $   / SQn/ SQn/ SQn[         R                  " U5      [         R                  " U5      [         R                  " U5      p2n[        R                  " XU5      n[	        UR
                  S5        [	        UR                  S5        g)a  
Data generated in R with
> set.seed(1)
> library("onewaytests")
> library("tibble")
> y <- c(rnorm(40, sd=10),
+        rnorm(30, sd=15),
+        rnorm(20, sd=20))
> x <- c(rep("one", times=40),
+        rep("two", times=30),
+        rep("eight", times=20))
> x <- factor(x)
> ag.test(y ~ x, tibble(y,x))

Alexander-Govern Test (alpha = 0.05)
-------------------------------------------------------------
data : y and x

statistic  : 1.359941
parameter  : 2
p.value    : 0.5066321

Result     : Difference is not statistically significant.
-------------------------------------------------------------
Example adapted from:
https://eval-serv2.metpsy.uni-jena.de/wiki-metheval-hp/index.php/R_FUN_Alexander-Govern

)(g5gb?gl"k g^s/@gQ\
@gRh gIF@gpZ>q@g7D @g-ѪZng(Q<.@gON/@g	Ogҷ%6gs&@gw)ܿg789Ŀgzp"@gzl @g57@g>m@*a"@g,ZbI@gX9
]?g3g1@gg"Jbgy:@j-g2A g;@gL97vp,+@gp/rg"@gfT|7g^v+g٘Yg0/gglA! &@go@)g!_5*gqTEgg1$@g	a, @gˤ$g9%gZ@gT6U'@gS g6aGn*@gO@g\\"g^4w@g0gr~5@gDP=@gٿԙg:4R/gOx]r!@gU4 gta)B@g,Gg2$@gD%?gI,VL&g@gч
;g5@gWJc@gYjK@@)gj7#@g<e,g}m(@gr2g#^9gr/P@g:RO!g'9?g6F
?gcʱ'gt*&gg~*0Ώ7@gWzx>gIK'@g?Ң@g7C5@g;C>ϯUg7@g)n}.^@gFQ?gsdlT6?Nr   rf   ri   r  r   r*  r)  )rn   rq  twoeightsolns        rw   test_compare_r"TestAlexanderGovern.test_compare_r  sn    :"	I7 **S/2::c?BJJu<M%$$Su5(=>%;<rz   c                 z   / SQn/ SQn/ SQn[         R                  " U5      [         R                  " U5      [         R                  " U5      p2n[        R                  " XU5      n[	        UR
                  SSS9  [	        UR                  SSS9   [	        UR
                  S	5        [	        UR                  S
5        g)z
Data taken from 'The Modification and Evaluation of the
Alexander-Govern Test in Terms of Power' by Kingsley Ochuko, T.,
Abdullah, S., Binti Zain, Z., & Soaad Syed Yahaya, S. (2015).
)g{G&~@g(\E~@g=
ףp~@gfffff~@gp=
~@gףp=
k@gR@gQ2@g8@g`@g)\`@g=
ףp@g(\#@g@g=
ףpE@gQ@g
ףp=@gףp=
Մ@g33333#@)g=
ףpt@g{G&u@gq=
ףv@gQDy@g     X{@g\(P}@g]~@gt~@gzG~@g)\~@g1@gzG@)gGz8@g     @gp=
ב@g
ףp=@gGzԀ@gq=
ףր@gRi@g{Gt@gw@g=
ףp@gQS@gQ@g(\©@gQ-@gQ@g]FxK@r  r3  g R8߱?r  g.UikL@g&Zݱ?Nr  )rn   youngmiddleoldr  s        rw   test_compare_scholar(TestAlexanderGovern.test_compare_scholar  s    08GZZ.

60BBJJsOs$$UC8T:W48	: 	1Z0rz   c                 D   / SQn/ SQn[         R                  " U5      [         R                  " U5      p![        R                  " X5      n[	        UR
                  SSS9  [	        UR                  SSS9   [	        UR
                  S5        [	        UR                  S5        g	)
a  
Data taken from 'Robustness And Comparative Power Of WelchAspin,
Alexander-Govern And Yuen Tests Under Non-Normality And Variance
Heteroscedasticity', by Ayed A. Almoied. 2017. Page 34-37.
https://digitalcommons.wayne.edu/cgi/viewcontent.cgi?article=2775&context=oa_dissertations
)gQhgMOgY9gnSgdȿg}"Ogиp $?g8~4?g
p?gZ?g)J=?gX?gpG?gᛦ?gg?gh8en?g?guwg?gbX?g9SI?)gN]g	cZgAJigMg'gk,	Pg<gΈ׿g%zrKտg0BxҿgPNg:ǀgvꭁg?k~?gI\߇?gi?g<)?g0Xr?g
F%u?gsFZ*o?g7n:?g[z4?r
  r3  gOZ}?g9$?g6MDd}?Nr  )rn   r  r  r  s       rw   test_compare_scholar3)TestAlexanderGovern.test_compare_scholar3  s|    "! BBB$$R,t<XD9	8 		2Y/rz   c                 6   [         R                  " / SQ5      [         R                  " S[         R                  /5      4n[        R                  " U6 n[        UR                  [         R                  5        [        UR                  [         R                  5        g )Nr  r   r   rf   rm   ri   r  r   r)  r*  )rn   r0  r   s      rw   test_nan_policy_propagate-TestAlexanderGovern.test_nan_policy_propagateO  sZ    zz,'QK)@@##T*SZZ(S]]BFF+rz   c                     [         R                  " / SQ5      [         R                  " S[         R                  /5      4n[        [        SS9   [
        R                  " USS06  S S S 5        g ! , (       d  f       g = f)Nr  r   r   r   r   r   )r   rf   rm   r   r   ri   r  )rn   r0  s     rw   test_nan_policy_raise)TestAlexanderGovern.test_nan_policy_raiseV  sQ    zz,'QK)@@:-LM!!4<G< NMMs   A--
A;c                    [         R                  " SSS[         R                  S/5      [         R                  " S[         R                  SS/5      4n[         R                  " / SQ5      [         R                  " / SQ5      4n[        R                  " US	S
06n[        R                  " U6 n[        UR                  UR                  5        [        UR                  UR                  5        g )Nr   r1   r2   r3   r  r  r  )r   r  r  r   r   r  )rn   args_nanargs_no_nanres_nan
res_no_nans        rw   test_nan_policy_omit(TestAlexanderGovern.test_nan_policy_omit[  s    ::q!Q23RZZBFFBPR@S5TTjj.

;0GG''EfE**K8
W^^Z%6%67W&&
(<(<=rz   c                    [         R                  " / SQ5      n[         R                  " / SQ5      n[        R                  " [        SS9   [
        R                  " X5      nS S S 5        [        WR                  [         R                  5        [        UR                  [         R                  5        g ! , (       d  f       NW= f)NrJ  rL  r  r   )r   rf   rP  rQ  r   ri   r  r   r*  rm   r)  )rn   r  r  r   s       rw   rU  'TestAlexanderGovern.test_constant_inputc  ss    ZZ-.ZZ-.\\.0LM''/C NS]]BFF+SZZ( NMs   
B22
C r   N)r   r   r   r   r  rP  r  r  r  r  r  r  r  r  r  r  rU  r   r   rz   rw   r  r    sz    >( [[Vq!fb\QFA;!Q!$NO- P-)B=H11f10f,=
>)rz   r  c            	          \ rS rSrS rS rS rS rS rS r	\
R                  R                  S\R                  " / S	Q5      \R                  " / S
Q5      \R                  S44\R                  " / S	Q5      \R                  " / S	Q5      \R                   \R                   44/5      S 5       r\
R                  R                  S/ SQ5      S 5       rS rS rS rS r\
R                  R                  SS/ SQ4/5      S 5       rS rS rSrg)TestFOneWayim  c                 n    [         R                  " SS/SS/5      u  p[        US5        [        US5        g )Nr   r1   r   r   ri   f_onewayr   rn   r  rT  s      rw   test_trivialTestFOneWay.test_trivialo  s0    ~~q!fq!f-QQrz   c                     [         R                  " SS/SS/5      u  p[        US5        [        US[        R
                  " S5      -
  SS9  g )	Nr   r1   r3   rm  r   r:   rX  r  )ri   r  r   r   r   r6  r  s      rw   rF  TestFOneWay.test_basicu  sA     ~~q!fq!f-Q1rwws|+%8rz   c                 p    [         R                  " S/S// SQ5      u  p[        US5        [        US5        g )Nr1   r  rk  r  r  r  s      rw   test_known_exactTestFOneWay.test_known_exact|  s2     ~~qcA3	2 	QQrz   c                     [         R                  " SS/[         R                  S9n[         R                  " SS/[         R                  S9n[        R                  " X5      u  p4[        USSS9  g )	N    rZ      gŸ?rX  r  )r   r   uint16ri   r  r   )rn   r9  rE  r  rT  s        rw   test_large_integer_array$TestFOneWay.test_large_integer_array  sQ    HHc3Zryy1HHc3Zryy1~~a# 	.U;rz   c                     [         R                  " SS/[         R                  S9n[         R                  " SS/[         R                  S9n[        R                  " X5      nSn[        X45        g )Nr  r  rZ  r  r  r  )r   r   r  ri   r  r   )rn   r9  rE  r   r,  s        rw   test_result_attributes"TestFOneWay.test_result_attributes  sM    HHc3Zryy1HHc3Zryy1nnQ",
C,rz   c                 :   / SQnU GHu  nSn[         R                  R                  [         R                  R                  [         R                  R	                  [
        5      SU5      5      n[        U5       nUR                  5       R                  S5      nS S S 5        WSS  Vs/ s H*  nUR                  5       (       d  M  UR                  5       PM,     nn[        R                  " USS9n	U	R                  u  pU
R                  [        5      n
[        R                  " U
5      n[!        US	   S
   5      nU Vs/ s H	  oX:H     PM     nn["        R$                  " U6 nSnUU;   a  Sn['        US	   XSSU 3S9  GMx     g ! , (       d  f       N= fs  snf s  snf )N)z
SiRstv.datz
SmLs01.datz
SmLs02.datz
SmLs03.datzAtmWtAg.datz
SmLs04.datz
SmLs05.datz
SmLs06.dat
SmLs07.dat
SmLs08.dat
SmLs09.datr  zdata/nist_anova
r  r  r9  )skiprowsr   rb   )r  r  r  r  zFailing testcase: )r  ra  )ospathabspathjoindirname__file__openreadsplitstripr   loadtxtr  r  r%  uniquer  ri   r  r   )rn   	filenames	test_caser  fnamer2  contentline	certifieddatafrq   rp   catyr  xlistr   hard_tcs                    rw   	test_nistTestFOneWay.test_nist  sT   ?	 #IDGGOOBGGLL1J1BI%O PEe&&(... 29"R. *.$ JJL &.I *JJur2E77DAA99Q<Dil2&'A(,-1qvYE-..%(C AGG#CFA&8$DF- # * .s   7 F&FF<F
F	za, b, expected)rm  rm  rm  r
  r   c                     Sn[         R                  " [        R                  US9   [        R                  " X5      u  pVU(       d	   Xc:H  5       e S S S 5        g ! , (       d  f       g = f)N%Each of the input arrays is constant;r   )rP  rQ  ri   rR  r  )rn   r9  rE  r  r   r2  rT  s          rw   rU  TestFOneWay.test_constant_input  sI     6\\%44C@>>!'DA#am#1 A@@s   )A
A'rW   )rQ  rb   r   r   c                 r   [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/5      n[         R                  " / SQ/ SQ/ SQ/ SQ/ S	Q/ S
Q/ SQ/ SQ/5      n[         R                  " / SQ/ SQ/ SQ/ SQ/5      nUS;   a'  UR                  nUR                  nUR                  nSnOSnSn[        R                  " [
        R                  US9   [
        R                  " X#XAS9u  pxS S S 5        S Hx  n	[
        R                  " [         R                  " X)U5      [         R                  " X9U5      [         R                  " XIU5      5      u  p[        WU	   U
SS9  [        WU	   USS9  Mz     S H  n	[        R                  " [
        R                  US9   [
        R                  " [         R                  " X)U5      [         R                  " X9U5      [         R                  " XIU5      5      u  p[        WU	   U
5        [        WU	   U5        S S S 5        M     g ! , (       d  f       GN:= f! , (       d  f       M  = f)N)r   r3   r2   r2   )r1   r4   r2   r2   )r2   r5   r2   r2   r#  )r2   r   r4   r2   )r3   r5   r4   r2   )r3   r2   r4   r2   )r   r4   r4   r2   )r4   r4   r4   r2   )r1   r2   r4   r2   )r7   r1   r4   r2   )r1   r1   r4   r2   )r3   r2   r3   r2   )r3   r1   r3   r2   )r4   r3   r3   r2   rb   r   r   r   r$  r   rV   rD  rX  r  rF  )r   r   r  rP  rQ  ri   rR  r  taker   r   )rn   rW   r9  rE  rY  	take_axisr,  r2  rT  r  fjpjs               rw   test_2d_inputsTestFOneWay.test_2d_inputs  s   HHl""""	$ %
 HHl"""""""$ % HHl"""$ %
 7?AAAII:\\%44HE>>!5DA F
 A^^BGGA)$<$&GGA)$<$&GGA)$<>FB AaD"51AaD"51  Ae88Ii(@(*i(@(*i(@B QqT2&QqT2& JI  FE JIs   
HA8H'
H$'
H6	c           
         S[         R                  " SS5      R                  SSS5      -  nS[         R                  " SS5      R                  SS	S5      -  n[         R                  " S[         R                  " SS
5      R                  SSS5      -  5      n[        R
                  " XUSS9u  pEUR                  S:X  d   eUR                  S:X  d   e[        UR                  S   5       Ho  n[        UR                  S   5       HP  n[        R
                  " XS S 2U4   X&S S 2U4   X6S S 2U4   5      u  p[        XXg4   5        [        XXg4   5        MR     Mq     g )Nr   r      r3   r4   r6   r1      r7   q   rV   )r3   r6   r   )	r   r   rk   cosri   r  r  r  r   )
rn   r9  rE  rY  r2  rT  r  r  fijpijs
             rw   test_3d_inputsTestFOneWay.test_3d_inputs  s%   biiY'//1a88biiY'//1a88FF1RYYsI.66q!Q??@~~aAA.ww&   ww&   qwwqz"A1771:& >>!q!G*a1aj!q!G*MqtW-qtW- ' #rz   c                     [         R                  " [        [        S9   [        R
                  " / SQ/ / SQ5      n[        U[        R                  [        R                  45        S S S 5        g ! , (       d  f       g = f)Nr   r  r  )	rP  rQ  r   r   ri   r  r   r   rm   r  s     rw   test_length0_1d_error!TestFOneWay.test_length0_1d_error   sH    \\,4IJ^^Ir<@F"&&"&&!12 KJJs   AA..
A<c                    [         R                  " [        [        S9   Sn[        R
                  " SU45      n[        R
                  " SU45      n[        R
                  " SU45      n[        R                  " X#U5      u  pV[        R                  " U4[        R                  S9n[        XW5        [        Xg5        S S S 5        g ! , (       d  f       g = f)Nr   r2   r3   r   r4   r  )rP  rQ  r   r   r   r  ri   r  r   rm   r   )rn   ncolsr9  rE  rY  r2  rT  nanss           rw   test_length0_2d_error!TestFOneWay.test_length0_2d_error   s    \\,4IJEE
#AE
#AE
#A>>!*DA77E87D!! KJJs   BC
Cc                     [         R                  " [        5         [        R                  " S/S/S/S/5      n[        U[        R                  [        R                  45        S S S 5        g ! , (       d  f       g = f)Nr\   r]   r^   r_   )rP  rQ  r   ri   r  r   r   rm   r  s     rw   test_all_length_oneTestFOneWay.test_all_length_one   sN    \\,-^^RD2$rd;F"&&"&&!12 .--s   AA,,
A:r0  r   r  c                 ~    Sn[        [        US9   [        R                  " U6   S S S 5        g ! , (       d  f       g = f)Nz$At least two samples are required...r   )r   r'  ri   r  )rn   r0  r  s      rw   test_too_few_inputsTestFOneWay.test_too_few_inputs   s)    89G4NND! 544s   .
<c                     [         R                  " S5      n[         R                  " S5      n[        [        5         [        R
                  " XSS9  S S S 5        g ! , (       d  f       g = f)Nr  r4   r3   r1   rV   )r   r  r   r&   ri   r  rn   r9  rE  s      rw   test_axis_errorTestFOneWay.test_axis_error   s>    GGFOGGFO9%NN1a( &%%   A
A)c                     [         R                  " S5      n[         R                  " S5      n[        [        5         [        R
                  " XSS9  S S S 5        g ! , (       d  f       g = f)Nr  rF  r   rV   )r   r  r   r   ri   r  rG  s      rw   test_bad_shapesTestFOneWay.test_bad_shapes#   s>    GGFOGGFO:&NN1a( '&&rJ  N)r   r   r   r   r  rF  r  r   r  r!  rP  r  r  r   r   r  rm   rU  r,  r5  r8  r=  r@  rC  rH  rL  r   r   rz   rw   r  r  m  s
   9<-F@ [[-	,	)!4rvvqkB	,	,!7"&&"&&9IJ0
 $	$ [[V^4-' 5-'^."3	"3
 [[Vb9,%78" 9"
))rz   r  c                   P    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rSrg)TestKruskali*   c                    S/nS/n[         R                  " X5      u  p4[        US5        [        U[         R                  R
                  R                  US5      5        [         R                  " [        R                  " U5      [        R                  " U5      5      u  p4[        US5        [        U[         R                  R
                  R                  US5      5        g )Nr   r1   r   )	ri   kruskalr   r
   r{  rm  r|  r   r   rn   rp   rq   hrT  s        rw   test_simpleTestKruskal.test_simple+   s    CC}}Q"QAu2277::1a@A}}RXXa["((1+6QAu2277::1a@Arz   c                    / SQn/ SQn[         R                  " X5      u  p4[        USSS9  [        U[         R                  R                  R                  SS5      5        [         R                  " [        R                  " U5      [        R                  " U5      5      u  p4[        USSS9  [        U[         R                  R                  R                  SS5      5        g )Nr   r1   r3   r5   r7   r\   r  r\   r  r   )ri   rQ  r
   r{  rm  r|  r   r   rR  s        rw   rF  TestKruskal.test_basic5   s    }}Q"Au"5Au2277::5!DE}}RXXa["((1+6Au"5Au2277::5!DErz   c                 h    S/nSS/nSnSnX4-  n[         R                  " X5      u  pg[        Xe5        g )Nr   r1   rf  r  )ri   rQ  r   rn   rp   rq   h_uncorrr  r  rS  rT  s           rw   test_simple_tieTestKruskal.test_simple_tie?   s=    CF*?}}Q" 	Q!rz   c                     / SQn/ SQnSnS[        S5      S-  -
  nX4-  n[        R                  " X5      u  pg[        Xe5        g )N)r   r   r   r1   )r1   r1   r1   r1   r1  r        )r  ri   rQ  r
   rZ  s           rw   test_another_tieTestKruskal.test_another_tieJ   sE    >5,-::?}}Q"A(rz   c                     / SQn/ SQnSS/nSnS[        S5      S-  -
  nXE-  n[        R                  " XU5      u  px[        Xv5        [        U[        R                  R
                  R                  US5      5        g )Nr  r*  r1   rO   r   r_  r`  )r  ri   rQ  r
   r{  rm  r|  )	rn   rp   rq   r-  r[  r  r  rS  rT  s	            rw   test_three_groupsTestKruskal.test_three_groupsS   ss    FG5,-::?}}Q1%A(Au2277::1a@Arz   c                    / SQn/ SQn/ n[         R                  " [        [        S9   [	        [
        R                  " XU5      [        R                  [        R                  45        S S S 5        g ! , (       d  f       g = f)Nr  r*  r   )	rP  rQ  r   r   r   ri   rQ  r   rm   )rn   rp   rq   r-  s       rw   r  TestKruskal.test_empty_   sP    \\,4IJqQ/"&&"&&1AB KJJs   A A11
A?c                 Z    / SQn/ SQn[         R                  " X5      nSn[        X45        g )Nr   rW  r  )ri   rQ  r   )rn   rp   rq   r   r,  s        rw   test_kruskal_result_attributes*TestKruskal.test_kruskal_result_attributesg   s'    mmA!,
C,rz   c                    [         R                  " S5      n[         R                  US'   [        [        R
                  " X5      [         R                  [         R                  45        [        [        R
                  " XSS9S5        [        [        [        R
                  XSS9  [        [        [        R
                  XSS9  g )Nr   r8   r   r   r  r   r   )	r   r   rm   r   ri   rQ  r   r   r   ru  s     rw   ry  TestKruskal.test_nan_policyn   su    IIcNvv!U]]1(266266*:;EMM!6BJOj%--'Jj%--(Krz   c                     Sn[         R                  R                  U5      n[         R                  R                  U5      S-   n[        R                  " X#5      u  pESn[        XV5        g )Nr>
  r   r   )r   r  ro  ri   rQ  r
   )rn   r  rp   rq   rS  rT  r  s          rw   test_large_no_samples!TestKruskal.test_large_no_samplesv   sM    IIOOAIIOOA#}}Q"A(rz   c                     Sn[         R                  " [        US9   [        R                  " 5         S S S 5        g ! , (       d  f       g = f)Nz-Need at least two groups in stats.kruskal\(\)r   )rP  r   r   ri   rQ  r&  s     rw   test_no_args_gh20661 TestKruskal.test_no_args_gh20661   s*    B]]:W5MMO 655s	   ;
A	r   N)r   r   r   r   rT  rF  r\  ra  rd  r  ri  ry  rn  rq  r   r   rz   rw   rO  rO  *   s9    BF	")
BC-L)rz   rO  zADelegation for `special.stdtr` only implemented for CuPy and JAX.)r!  
exceptionsrF   c                      \ rS rSr\R
                  R                  S/ SQ5      S 5       r\R
                  R                  S/ SQSS4/ S	QS
S4/5      S 5       r/ SQr	\R
                  R                  S/ SQ5      \R
                  R                  S\	5      S 5       5       r
\R
                  R                  S\	5      S 5       r\R
                  R                  S\	5      \R
                  R                  SSS/5      S 5       5       rSrg)TestCombinePvaluesi   z+method, expected_statistic, expected_pvalue))r  g'"x-@g({#H?)stoufferv!:@/?)rw  gQ4gF?)tippettr  gL^i?)mudholkar_georgegzP@guKqN?c                     / SQn[         R                  " UR                  U5      US9n[        UR                  UR                  U5      5        [        UR
                  UR                  U5      5        g )Nr  r  r4  r  )ri   combine_pvaluesrf   r/   r*  r)  )rn   ro   r  r  r  rp   r   s          rw   test_reference_values(TestCombinePvalues.test_reference_values   sR     ##BJJqM&Arzz2D'EF

BJJ$?@rz   z,weights, expected_statistic, expected_pvaluer   r   r   rw  rx  )r   r   r   ga;?grmT?c                    UR                  / SQ5      n[        R                  " USUR                  U5      S9n[        UR                  UR                  U5      5        [        UR
                  UR                  U5      5        g )Nr|  rv  )r  r
  )rf   ri   r}  r/   r*  r)  )rn   ro   r
  r  r  rp   r   s          rw   test_weighted_stouffer)TestCombinePvalues.test_weighted_stouffer   s^     JJ}%##Aj"**WBUVrzz2D'EF

BJJ$?@rz   )r  rw  ry  rv  rz  rY  )singlerc  r  r  c                 4   [        UR                  S5      5      nSu  pV[        R                  R	                  S5      nUS:X  an  UR                  UR                  UR                  U5      5      XV45      nUR                  UR                  UR                  SSU5      S5      US S 2SS 24   /SS9nOjUS	:X  a/  UR                  UR                  SSU5      Xe45      R                  nO5US
:X  a/  UR                  UR                  UR                  SSXV4S95      SS9nUR                  [        WR                  S   5       V	s/ s H!  n	[        R                  " XS S 24   US9S   PM#     sn	5      n
UR!                  U
SS  U
S S -
  S:  5      (       d   eg s  sn	f )Nr   )r\   r6   l	   TrU(	"b-= r  r1  r3  r'  rV   rc  r  r   r  r  rb   )r)   rf   r   r  r  r]  r  rk   r!  r  r  r  r  r  ri   r}  rc  )rn   rY  r  ro   r   r  r  r  pvaluessr  combined_pvaluess              rw   test_monotonicity$TestCombinePvalues.test_monotonicity   s    ""**Q-0ii##$KL hrzz#**Q-'@1&IH~~rzz"++c32JG'T'/12'8>? & AHr{{3Q'?!HJJH ||BJJs{{1aqf{/M$NUV|WH::8>>!,-'
- !!(a4.@C-'
  vv&qr*-=cr-BBaGHHHH	'
s   (Fc                     [         R                  " UR                  / SQ5      US9n[        UR                  US   5        [        UR
                  US   5        g )Nr|  r  r   r   )ri   r}  rf   r0   r*  r)  )rn   r  ro   r   s       rw   r?  TestCombinePvalues.test_result   sA    ##BJJ}$=fMs1v.

CF+rz   rW   r   r   c                 V   [         R                  R                  S5      nUR                  UR                  SS95      nUS:X  a  UR                  OUn[
        R                  " XRUS9nUcg  UR                  US5      n[
        R                  " XQS9n[        UR                  UR                  5        [        UR                  UR                  5        g US:X  a  UR                  OUnUSS S 24   USS S 24   p[
        R                  " XS9n
[
        R                  " XS9n[        UR                  S   U
R                  5        [        UR                  S   UR                  5        [        UR                  S   U
R                  5        [        UR                  S   UR                  5        g )	Nl   2'$FV r
  r  r   )rW   r  r  r  r   )r   r  r  rf   r  ri   r}  rk   r/   r*  r)  )rn   r  rW   ro   r  rp   r   r  r  r  ref0ref1s               rw   r  TestCombinePvalues.test_axis   sB   
 ii##O4JJszzwz/0AIACCA##A@<

1e$A''9CCMM3==9CJJ

3AIACCA1a4!AqD'B$$R7$$R7a($..9a($..9

1t{{3

1t{{3rz   r   N)r   r   r   r   rP  r  r  r~  r  r  r  r?  r  r   r   rz   rw   ru  ru     s-    [[5	GHAHA [[ 	7
)+>	?
)+=	>	@	AA	AA OG[[Y(CD[[Xw/I 0 EI2 [[Xw/, 0,
 [[Xw/ [[VaV,4 - 04rz   ru  c                   6    \ rS rSrSrS rS rS rS rS r	Sr
g	)
TestCdfDistanceValidationi   z[
Test that _cdf_distance() (via wasserstein_distance()) raises ValueErrors
for bad inputs.
c           	          [        [        [        R                  S/S/S/SS/5        [        [        [        R                  S/S/SS/5        g )Nr   r1   r3   r2   r   r   r   ri   wasserstein_distancerh  s    rw   &test_distinct_value_and_weight_lengths@TestCdfDistanceValidation.test_distinct_value_and_weight_lengths   sG     	j%"<"<cA3aV	-j%"<"<qcA3AOrz   c                     [        [        [        R                  SS/S/SS/5        [        [        [        R                  SS/S/SS/S/5        g )Nr   r   r1   r2   r  rh  s    rw   test_zero_weight*TestCdfDistanceValidation.test_zero_weight   sN     	j%"<"<!fqcAq6	+j%"<"<!fqcAq6A3	0rz   c           	      X    [        [        [        R                  SS/SS/SS/SS/5        g )Nr   r   r1   r2   rb   r  rh  s    rw   test_negative_weights/TestCdfDistanceValidation.test_negative_weights!  s-    j%"<"<!fq!fq!fq"g	7rz   c                     [        [        [        R                  / SS/5        [        [        [        R                  S// 5        g r  r  rh  s    rw   test_empty_distribution1TestCdfDistanceValidation.test_empty_distribution!  s2     	j%"<"<b1a&Ij%"<"<qc2Frz   c           	      v    [        [        [        R                  / SQSS/S[        R
                  S/SS/5        g )Nrg  r   )r   r   ri   r  r   r  rh  s    rw   test_inf_weight)TestCdfDistanceValidation.test_inf_weight!  s0    j%"<"<!Q!RVVQ!Q	Arz   r   N)r   r   r   r   r   r  r  r  r  r  r   r   rz   rw   r  r     s#    
P07
GArz   r  c                   t   \ rS rSrSrS r\R                  R                  SS5      \R                  R                  SS5      \R                  R                  SS	5      S
 5       5       5       r	\R                  R                  SS5      \R                  R                  SS5      \R                  R                  SS5      S 5       5       5       r
\R                  R                  SS5      \R                  R                  SS5      \R                  R                  SS5      S 5       5       5       rS r\R                  R                  SS5      \R                  R                  SS5      \R                  R                  SS5      S 5       5       5       r\R                  R                  SS5      \R                  R                  SS5      \R                  R                  SS5      S 5       5       5       rS r\R                  R                  S/ SQ5      \R                  R                  S/ SQ5      S 5       5       rS rg!)"TestWassersteinDistanceNDi!  z7Tests for wasserstein_distance_nd() output values.
    c                    / SQn/ SQn[         R                  " X5      n[        R                  " / SQ5      n[        R                  " / SQ5      n[        R                  " XE-  5      [        R                  " U5      -  n[        X65        g )N)rE  rE  rE  rE  rE  rE  rE  rE  rE  rE  )r3   r1   r5   r   r  )r  r  r0  r0  r0  r	  r	  r	  r	  r	  r	  r	  )r6   r   )rm  r1  rO   r   r   r   )r   gw@r   rb  r   r   )ri   wasserstein_distance_ndr   r   rM  r   )rn   r  r  r   flowdistr  s          rw   test_published_values/TestWassersteinDistanceND.test_published_values!  sg    
"" ++A1 xx01xx@AffT[!"&&,.!rz   n_value)r3   r  r4  r  )r2   r3   r6   max_repeats)r4   r\   c                    [         R                  R                  S5      nUR                  SX2[        S9nUR                  X!4S9n[         R
                  " XeSS9nUR                  [         R                  " U5      5      n[         R
                  " [         R                  " [        U5      5      U5      n	[         R                  " XS9n
UR                  [        U5      5      nX{   X   p[        R                  " XgX5      n[        USSS	9  g )
Nl   na{F.aP	 r   )r  rX  r  r   rV   r
  r2  r3  )r   r  r  integersr%  r
  rM  r   r  bincountr  ri   r  r   )rn   r  r  r  r  repeatsu_valuesv_values	v_weightsrange_repeat	u_weightsr	  r   s                rw   test_same_distribution_nD3TestWassersteinDistanceND.test_same_distribution_nD.!  s     ii##$<=,,q+3,G::G?:399XQ7JJrvvg/	yy3w<!8'BKK@	I/&oy/?)++H	UQU+rz   nu)r7   r8   &   nv)r7   r^   rd   )r2   r4   r  c                 r   [         R                  R                  S5      nUR                  X4S9n[         R                  " X#45      nUR                  US9nUR                  US9n[         R                  " [         R
                  R                  USS9US9n	[        R                  " XVXx5      n
[        X5        g )N   }&=:! r  r   rV   r
  )
r   r  r  rH  r&  r  rG  ri   r  r   )rn   r  r  r  r  r  r  r  r  r  r   s              rw   test_collapse_nD*TestWassersteinDistanceND.test_collapse_nDB!  s     ii##$89::B::.88RJ'JJBJ'	JJBJ'	jjq99M++H	U!rz   )r7   r   r  )r   r1   r5   c                    [         R                  R                  S5      nUR                  X4S9nUR                  X#4S9nUR                  US9nUR                  US9n[        R                  " XVXx5      n	UR                  SUSS9u  pUR                  X4S9n[         R                  " XZUSS9n[         R                  " Xz[         R                  " U5      SS9n[        R                  " XVXx5      n[        X5        g )Nr  r  r   r1   rV   )	r   r  r  ri   r  r  insertrH  r   )rn   r  r  r  r  r  r  r  r  r  add_rownrows	add_valuer   s                 rw   test_zero_weight_nD-TestWassersteinDistanceND.test_zero_weight_nDR!  s    
 ii##$89::B::.::B::.JJBJ'	JJBJ'	++H	Ua!4JJUMJ2	99X	BIIi"((5/J	++H	U!rz   c                     SS/SS//[         R                  [         R                  * //SS/p2n[        R                  " XU5      n[	        U[         R                  5        [         R
                  " SS9   [         R                  [         R                  //[         R                  [         R                  * //p![        R                  " X5      n[	        U[         R                  5        S S S 5        g ! , (       d  f       g = f)Nr   r1   r}  r~  )r   r  ri   r  r   r  rm   )rn   uvvvuwdistances        rw   test_inf_values)TestWassersteinDistanceND.test_inf_valuese!  s     !fq!f%"&&(9':QF00<Xrvv&[[*vvrvv&'266BFF7*;)<44R<H266* +**s   3A3C//
C=r	  )r   r2   r4   c                    [         R                  R                  S5      nUR                  X4S9nUR                  X#4S9nUR                  US9nUR                  US9n[        R                  " XVXx5      n	UR                  SU5      n
UR                  5       n[         R                  " XZUSS9n[         R                  " XjUSS9n[        R                  " XVXx5      n[        X5        g )Nl   Lq/ r  r   r   rV   )r   r  r  ri   r  r  r  r   )rn   r  r  r  r  r  r  r  r  r  add_dimr  r   s                rw   test_multi_dim_nD+TestWassersteinDistanceND.test_multi_dim_nDp!  s    
 ii##$78::B::.::B::.JJBJ'	JJBJ'	++H	U,,q$'JJL	99X	B99X	B++H	U!rz   )r6   r_   r  )r1   r3   r6   c                    [         R                  R                  S5      nUR                  X4S9nUR                  X#4S9nUR                  US9nUR                  US9n[        R                  " XVXx5      n	[        R
                  " U5      n
U
R                  US9nUR                  US9n[        R                  " X[-  U-   Xk-  U-   Xx5      n[        X5        g )Nl   uAh~r  r  )r   r  r  ri   r  ortho_groupr  r   )rn   r  r  r  r  r  r  r  r  r  r  	transformshiftr   s                 rw   test_orthogonal_nD,TestWassersteinDistanceND.test_orthogonal_nD!  s     ii##N3::B::.::B::.JJBJ'	JJBJ'	++H	U  &HH#H.	


%++H,@5,H)1)=)E)2? 	!rz   c                    [         R                  R                  S5      n[        R                  " [
        SS9   UR                  SS9nUR                  SS9n[        R                  " X#5      nS S S 5        [        R                  " [
        SS9   UR                  SS9nUR                  S	S9n[        R                  " X#5      nS S S 5        [        R                  " [
        S
S9   UR                  SS9nUR                  SS9n[        R                  " X#5      nS S S 5        g ! , (       d  f       N= f! , (       d  f       Nv= f! , (       d  f       g = f)Nl   e36^[Y{lz Invalid input values. The inputsr   )r3   r\   r  r  )r5   r1   r6   z Invalid input values. Dimensions)r  )r2   r  z(Invalid input values. If two-dimensionalr
  r1  )r   r  r  rP  r   r   ri   r  )rn   r  r  r  r  s        rw   test_error_code)TestWassersteinDistanceND.test_error_code!  s   ii##$>?]]:-OPzz{z3Hzzyz1H--hAA Q ]]:-OPzzuz-Hzzwz/H--hAA Q ]]:<>zzwz/Hzzvz.H--hAA	> > QP QP> >s#   5D#5D4%5E#
D14
E
Eu_size)r   r\   r   v_sizec                 h   [         R                  R                  S5      nUR                  US4S9nUR                  US4S9nUR                  5       nUR                  5       n[        R
                  " Xg5      n[        R                  " XE5      n	[        R                  " Xg5      n
[        X5        [        X5        UR                  US9nUR                  US9n[        R
                  " XgX5      n[        R                  " XEX5      n	[        R                  " XgX5      n
[        X5        [        X5        g )Nl   Ku@* r   r  )r   r  r  r  ri   r  r  r   )rn   r  r  r  r  r  u_values_flatv_values_flatd1d2d3r  r  s                rw   test_optimization_vs_analytical9TestWassersteinDistanceND.test_optimization_vs_analytical!  s	    ii##K0::FA;:/::FA;:/ ( ( ''E**8>**=HJJFJ+	JJFJ+	''(1>**8(1>**=(1>rz   r   N)r   r   r   r   r   r  rP  r  r  r  r  r  r  r  r  r  r  r   r   rz   rw   r  r  !  s   "& [[Y4[[VY/[[]G4, 5 0 5," [[T:.[[T;/[[VZ0" 1 0 /" [[T;/[[T;/[[VY/" 0 0 0" 	+ [[T<0[[T<0[[VY/" 0 1 1"" [[T;/[[T;/[[VY/" 0 0 0"$B  [[X{3[[X{3  4 4 rz   r  c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)TestWassersteinDistancei!  z4Tests for wasserstein_distance() output values.
    c                 D   [        [        R                  " SS/S/SS/S/5      S5        [        [        R                  " SS/S/SS/S/5      S5        [        [        R                  " SS/S/SS/S/5      S5        [        [        R                  " / SQ/ SQ5      S5        g )	Nr   r   r:   r2   rp  r1   r  r  r   ri   r  rh  s    rw   rT  #TestWassersteinDistance.test_simple!  s     	&&1vsQFQC@	 	22FQC!Q!&	 	22FQC!Q!&	 	22y"	rz   c           	          [        [        R                  " / SQ/ SQ5      S5        [        [        R                  " / SQSS// SQSS/5      S5        g 	Nr  rd  r   )r   r   r   r3   r3   r   r=  r2   )r   ri   r  rh  s    rw   test_same_distribution.TestWassersteinDistance.test_same_distribution!  sE     	U//	9EqI&&|aV'3aV=	rz   c           	      0   [        [        R                  " S/S/5      S5        [        [        R                  " S/S/5      S5        [        [        R                  " / SQ/ SQ5      S5        [        [        R                  " / SQ/ S	Q/ S
Q/ SQ5      S5        g )Nr   r   r  r4   r\   r  )r]   r^   r_   rZ   r  )r>   g@rt
  )rq
  r6   r  )r2   r   r   )r   r2   r   r<   r  rh  s    rw   
test_shift"TestWassersteinDistance.test_shift!  sz     	22A3<a@22B4!=rB&&8LM	 	&&'0)=	rz   c           
          [        [        R                  " / SQ/ SQ/ SQ/ SQ5      [        R                  " / SQ/ SQ/ SQ/ SQ5      5        g N)r   r   r   r   r   r   r4   )r   r2   r2   r2   r2   r3   r3   )r   r   r   r   r   r   r   )r4   r   r   )r   r3   r2   r   r1   r3   r  rh  s    rw   test_combine_weights,TestWassersteinDistance.test_combine_weights!  s?     	&&%'<%'<> &&y)'0)=		>rz   c                    [         R                  " SSS5      n[         R                  " U5      n[        [        R
                  " X5      [         R                  " [         R                  " U5      5      5        [         R                  " [        U5      5      nUS S S2   n[        [        R
                  " XX45      [         R                  " [         R                  " U5      US95        g )Nr  r  r4  rb   r
  )
r   r   r  r   ri   r  rl   r  r  r&  )rn   r  r  r  r  s        rw   test_collapse%TestWassersteinDistance.test_collapse!  s     IIc2s#MM!&&q,GGBFF1I	  IIc!f%	ddO	&&qYBJJrvvay)4	6rz   c           
          [        [        R                  " / SQSS// SQSS/5      [        R                  " SS/SS/SS/SS/5      5        g N)r   r1   rZ  r   r	  r1   r  rh  s    rw   r  (TestWassersteinDistance.test_zero_weight
"  sN    &&~1v'01a&:&&1v1v1v1vF	Hrz   c                    [        [        R                  " SS[        R                  /SS/5      [        R                  5        [        [        R                  " SS[        R                  /[        R                  * S/5      [        R                  5        [        [        R                  " S[        R                  * [        R                  /SS/5      [        R                  5        [        5        nUR                  [        S5        [        [        R                  " SS[        R                  /[        R                  S/5      [        R                  5        S S S 5        g ! , (       d  f       g = fNr   r1   r   )	r   ri   r  r   r  r   r   r   rm   rn   r   s     rw   r  'TestWassersteinDistance.test_inf_values"  s     	&&1bff~1v>FF	 	&&1bff~|DFF	 	&&BFF7BFF';aVDFF	  CJJ~'78**Aq"&&>BFFA;G !     /A'E
E-r   N)r   r   r   r   r   rT  r  r  r  r  r  r  r   r   rz   rw   r  r  !  s+     >6 Hrz   r  c                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)TestEnergyDistancei$"  z/Tests for energy_distance() output values.
    c                    [        [        R                  " SS/S/SS/S/5      [        R                  " S5      S-  5        [        [        R                  " SS/S/SS/S/5      [        R                  " S5      S-  5        [        [        R                  " SS/S/SS/S/5      S5        [        [        R                  " / SQ/ S	Q5      [        R                  " S5      S
-  5        g )Nr   r   r1   r:   r2   rp  r   r  r  ra  r   ri   energy_distancer   r6  rh  s    rw   rT  TestEnergyDistance.test_simple("  s     	!!1a&1#1vs;GGAJO	 	E11FQC!Q!&GGAJ	 	E11FQC!Q!&	 	!!)Y7GGAJ**	,rz   c           	          [        [        R                  " / SQ/ SQ5      S5        [        [        R                  " / SQSS// SQSS/5      S5        g r  )r   ri   r  rh  s    rw   r  )TestEnergyDistance.test_same_distribution8"  sB     	U**9i@!D!!,Aq!fM	rz   c                     [        [        R                  " S/S/5      [        R                  " S5      5        [        [        R                  " S/S/5      [        R                  " S5      S-  5        g )Nr   r   r1   r  r4   gS[:XL	@r  rh  s    rw   r  TestEnergyDistance.test_shift@"  sS     	E111#s;RWWQZH!!2$,GGAJ	!rz   c           
          [        [        R                  " / SQ/ SQ/ SQ/ SQ5      [        R                  " / SQ/ SQ/ SQ/ SQ5      5        g r  r   ri   r  rh  s    rw   r  'TestEnergyDistance.test_combine_weightsH"  s<     	!!"79N"79NP!!)Y	9M	Orz   c           
          [        [        R                  " / SQSS// SQSS/5      [        R                  " SS/SS/SS/SS/5      5        g r  r  rh  s    rw   r  #TestEnergyDistance.test_zero_weightP"  sK    !!.1a&)aVL!!1a&1a&1a&1a&A	Crz   c                    [        [        R                  " SS[        R                  /SS/5      [        R                  5        [        [        R                  " SS[        R                  /[        R                  * S/5      [        R                  5        [        [        R                  " S[        R                  * [        R                  /SS/5      [        R                  5        [        5        nUR                  [        S5        [        [        R                  " SS[        R                  /[        R                  S/5      [        R                  5        S S S 5        g ! , (       d  f       g = fr  )	r   ri   r  r   r  r   r   r   rm   r  s     rw   r  "TestEnergyDistance.test_inf_valuesV"  s     	U**Aq"&&>Aq6BBFFK!!1a.BFF7A,?FF	 	!!1rvvgrvv"6A?FF	  CJJ~'78%%q!RVVnrvvqkB !  r   r   N)r   r   r   r   r   rT  r  r  r  r  r  r   r   rz   rw   r  r  $"  s'    , !OCrz   r  c                       \ rS rSr/ SQr/ SQrSrS rS rS r	S r
S	 rS
 r\R                  R                  SS/ 0S/ 0/ / S./5      S 5       rS rS rS rS rS rSrg)TestBrunnerMunzelig"  )r   r1   r   r   r   r   r   r   r   r   r1   r3   r   r   r2   r2   r3   r2   r   r1   r2   r   r   r4   r3   r_   c                    [         R                  " U R                  U R                  SS9u  p[         R                  " U R                  U R                  SS9u  p4[         R                  " U R                  U R                  SS9u  pV[         R                  " U R                  U R                  SS9u  px[	        X$U R
                  S9  [	        XhU R
                  S9  [        X&:g  5        [	        USU R
                  S9  [	        USU R
                  S9  [	        USU R
                  S9  [	        USU R
                  S9  [	        USU R
                  S9  [	        USU R
                  S9  g )	Nr~  r  r  r  |	&	@|	&	gҏGg?g@-pL?)ri   brunnermunzelrg   rU
  r
   r  r   rV
  s	            rw   test_brunnermunzel_one_sided.TestBrunnerMunzel.test_brunnermunzel_one_sidedm"  s(   $$TVVTVVH$$TVVTVVK$$TVVTVVK$$TVVTVVHB0@0@AB0@0@AB 2(,(8(8	:B 3(,(8(8	:B 2(,(8(8	:B 3(,(8(8	:B 5(,(8(8	:B 3(,(8(8	:rz   c                 Z   [         R                  " U R                  U R                  SS9u  p[         R                  " U R                  U R                  SS9u  p4[	        X$U R
                  S9  [	        USU R
                  S9  [	        USU R
                  S9  [	        USU R
                  S9  g )Nr|  r  r  r  r   ҏGw?ri   r  rg   rU
  r
   r  r`
  s        rw   test_brunnermunzel_two_sided.TestBrunnerMunzel.test_brunnermunzel_two_sided"  s    $$TVVTVVM$$TVVTVVMB0@0@AB 2(,(8(8	:B 3(,(8(8	:B 5(,(8(8	:rz   c                 ^   [         R                  " U R                  U R                  5      u  p[         R                  " U R                  U R                  5      u  p4[	        X$U R
                  S9  [	        USU R
                  S9  [	        USU R
                  S9  [	        USU R
                  S9  g )Nr  r  r  r  r  r`
  s        rw   test_brunnermunzel_default,TestBrunnerMunzel.test_brunnermunzel_default"  s    $$TVVTVV4$$TVVTVV4B0@0@AB 2(,(8(8	:B 3(,(8(8	:B 5(,(8(8	:rz   c           	          SnSnSn[        US;  5        [        [        [        R                  U R
                  U R                  UUU5        g )Nr  r  r  r  r   r   r   ri   r  rg   rU
  rn   r  distributionr   s       rw   $test_brunnermunzel_alternative_error6TestBrunnerMunzel.test_brunnermunzel_alternative_error"  sI     
#CCDj))ffff!" 	"rz   c                 Z   [         R                  " U R                  U R                  SS9u  p[         R                  " U R                  U R                  SS9u  p4[	        X$U R
                  S9  [	        USU R
                  S9  [	        USU R
                  S9  [	        USU R
                  S9  g )Nr  r&  r  r  r  g "H[?r  r`
  s        rw   $test_brunnermunzel_distribution_norm6TestBrunnerMunzel.test_brunnermunzel_distribution_norm"  s    $$TVVTVV(K$$TVVTVV(KB0@0@AB 2(,(8(8	:B 3(,(8(8	:B 5(,(8(8	:rz   c           	          SnSnSn[        US;  5        [        [        [        R                  U R
                  U R                  UUU5        g )Nr|  r  r  )r  r  r$  r%  s       rw   %test_brunnermunzel_distribution_error7TestBrunnerMunzel.test_brunnermunzel_distribution_error"  sH    ! 
?23j))ffff!" 	"rz   kwarg_updaterq   rp   rT  c                 ^   U R                   U R                  S.nUR                  U5        [        R                  " [
        [        S9   [        R                  " S0 UD6u  p4S S S 5        [        W[        R                  5        [        W[        R                  5        g ! , (       d  f       NC= f)NrT  r   r   )rg   rU
  r  rP  rQ  r   r   ri   r  r   r   rm   )rn   r0  r1  r*  r)  s        rw   test_brunnermunzel_empty_imput0TestBrunnerMunzel.test_brunnermunzel_empty_imput"  st     vvDFF+l#\\,4IJ % 3 3 =f =I KY'VRVV$ KJs   B
B,c                 v   SSSSSSSSSSSSSS[         R                  /n/ SQn[        R                  " XSS9u  p4[        R                  " X!SS9u  pV[	        U[         R                  5        [	        U[         R                  5        [	        U[         R                  5        [	        U[         R                  5        g )Nr   r1   r3   r  r  r   )r   rm   ri   r  r   rn   rg   rU
  rW
  r  rX
  r	  s          rw   &test_brunnermunzel_nan_input_propagate8TestBrunnerMunzel.test_brunnermunzel_nan_input_propagate"  s    1aAq!Q1aArvv>-$$QkB$$QkBR R R R rz   c                     SSSSSSSSSSSSSS[         R                  /n/ SQnSnSnSn[        [        [        R
                  UUUUU5        [        [        [        R
                  UUUUU5        g )Nr   r1   r3   r  r|  r  r   )r   rm   r   r   ri   r  )rn   rg   rU
  r  r&  r   s         rw   "test_brunnermunzel_nan_input_raise4TestBrunnerMunzel.test_brunnermunzel_nan_input_raise"  s    1aAq!Q1aArvv>-!
j))!" 	" 	j))!" 	"rz   c                 L   SSSSSSSSSSSSSS[         R                  /n/ SQn[        R                  " XSS9u  p4[        R                  " X!SS9u  pV[	        XFU R
                  S9  [	        USU R
                  S9  [	        US	U R
                  S9  [	        US
U R
                  S9  g )Nr   r1   r3   r  r   r   r  r  r  r  )r   rm   ri   r  r
   r  r5  s          rw   !test_brunnermunzel_nan_input_omit3TestBrunnerMunzel.test_brunnermunzel_nan_input_omit"  s    1aAq!Q1aArvv>-$$Qf=$$Qf=B0@0@AB 2(,(8(8	:B 3(,(8(8	:B 5(,(8(8	:rz   c                     / SQn/ SQnSn[         R                  " [        US9   [        R                  " XSS9  SSS5        g! , (       d  f       g= f)zktests that a warning is emitted when p is nan
p-value with t-distributions can be nan (0/0) (see gh-15843)
r  r  zDp-value cannot be estimated|divide by zero|invalid value encounteredr   r  r*  N)rP  rQ  r   ri   r  r  s       rw   test_brunnermunzel_return_nan/TestBrunnerMunzel.test_brunnermunzel_return_nan"  s=     T\\.437 544s   A
Ac                     / SQn/ SQn[         R                  " [        SS9   [        R                  " XSS9u  p4SSS5        [        WS5        g! , (       d  f       N= f)	z^tests that a p is 0 for datasets that cause p->nan
when t-distribution is used (see gh-15843)
r  r  zdivide by zeror   r  r*  Nr   )rP  rQ  r   ri   r  r   )rn   rp   rq   r  rT  s        rw   test_brunnermunzel_normal_dist0TestBrunnerMunzel.test_brunnermunzel_normal_dist#  sK     \\.0@A&&q(CDA BQ BAs   A
Ar   N)r   r   r   r   rg   rU
  r  r  r  r!  r'  r+  r.  rP  r  r  r2  r6  r9  r<  r?  rB  r   r   rz   rw   r  r  g"  s    2A)AK:.::"	:" [[^sBi#r46R.@.B C%C%	!",:	8	rz   r  c                      \ rS rSrSrS r\R                  R                  S/ SQ/ SQSS\	R                  * S	S
/SSS\	R                  S//5      S 5       r\R                  R                  S/ SQ/ SQ/5      S 5       r\R                  R                  SSS/5      \R                  R                  SS
S/5      \R                  R                  SSS/5      S 5       5       5       rS rSrg)TestQuantileTesti#  zYTest the non-parametric quantile test,
including the computation of confidence intervals
c                 B   / SQnSn[         R                  " [        US9   [        R                  " U/5        S S S 5        Sn[         R                  " [        US9   [        R                  " USS/S9  S S S 5        Sn[         R                  " [        US9   [        R                  " US	S
/S9  S S S 5        [         R                  " [        US9   [        R                  " USS9  S S S 5        [         R                  " [        US9   [        R                  " USS9  S S S 5        Sn[         R                  " [        US9   [        R                  " USS9  S S S 5        Sn[         R                  " [        US9   [        R                  " U5      R                  S5        S S S 5        g ! , (       d  f       GNv= f! , (       d  f       GNM= f! , (       d  f       GN$= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       g = f)Nr  z/`x` must be a one-dimensional array of numbers.r   z`q` must be a scalar.r   r1   )r6  z-`p` must be a float strictly between 0 and 1.r:   r  )rT  ro  z`alternative` must be one of...z	one-sidedr  r!  )rP  r   r   ri   quantile_testro  r  s      rw   test_quantile_test_iv&TestQuantileTest.test_quantile_test_iv#  sn   C]]:W5$ 6 *]]:W5aV, 6 B]]:W5c4[1 6]]:W5Q' 6]]:W5T* 6 4]]:W5{; 6 I]]:W5"66q9 65) 65 65 655555 65 65sS   F'F9GGG.?G?8&H'
F69
G
G
G+.
G<?
H
Hzp, alpha, lb, ub, alternative)r4  r`  gX݊?g蜶?r|  )r:   r3  g-tA?gP"?r|  rp  r`  g{gA?r~  rD  r3  gg @r  c                     [         R                  " [         R                  " SSS5      5      n[        R                  " XaUS9n[        UR                  U5      X4/SS9  g )Nr   r  r  )rT  r  r2  r  )r   r  r   ri   rG  r   ro  )rn   rT  r$  lbubr  rp   r   s           rw   test_R_ci_quantile#TestQuantileTest.test_R_ci_quantile3#  sJ      FF299Qd+,!!!kB//6uMrz   zq, p, alternative, ref)rm  r4  r|  gͯI	?)r  r:   r|  gɍQ%e?c                     [         R                  " [         R                  " SSS5      5      n[        R                  " XQX#S9n[        UR                  USS9  g )Nr   r  r  r6  rT  r  r9   r  )r   r  r   ri   rG  r   r)  )rn   r6  rT  r  r  rp   r   s          rw   test_R_pvalueTestQuantileTest.test_R_pvalueG#  sA     FF299Qd+,!!!AG

Ce4rz   r  
continuousdiscreter  r$  c                    [        S[        U5      -  [        U5      -   U-  5      n[        R                  R	                  U5      nUS:X  a!  UR                  SS9u  pgUR                  SS9nO3UR                  SSSS9nUR                  5       nUR                  SS5      n[        R                  " XXbS9n	U	R                  US	9n
US
:X  a  XR                  :*  nOXR                  :  nX    H-  n[        R                  " XXbS9n	U	R                  SU-
  :  a  M-   e   X)     H-  n[        R                  " XXbS9n	U	R                  SU-
  :  a  M-   e   g )Nr6   rS  r1   r  r  r   r]   rP  r  r~  )r%  r  r   r  r  r  ri   rG  ro  rs  rr  r)  )rn   r  r  r$  rn  r  rT  r6  r  r   r  i_insiderp   s                rw   test_pval_ci_match#TestQuantileTest.test_pval_ci_matchV#  sC    As4yL3{#33U:;ii##D)<::1:%DA**#*&C,,q"3,/C

AQ#A!!#aI$$e$< & gg~Hff}HA%%c!MC::E	)))  YA%%c!MC::E	)))  rz   c                    / SQnSn[         R                  " USSSS9n[        UR                  USS9  S	/S
-  S/S-  -   n[         R                  " SSS9R                  S
S9n[         R                  " USSSS9n[        UR                  USS9  g )N)                                    r,        geX?re  r  r|  rP  r
  r  ;   r7   rX   h   r:   p   )rT  r  rz  r9  r  r  r3  )ri   rG  r   r)  r   rN  )rn   rp   pvalue_expectedr   s       rw   test_match_conover_examples,TestQuantileTest.test_match_conover_examples#  s     !!!sdL

O$? DFbT5\!++s377!7<!!!rSiH

O%@rz   r   N)r   r   r   r   r   rH  rP  r  r  r   r  rM  rQ  rW  rl  r   r   rz   rw   rE  rE  #  s   :6 [['	G	F
rvvg/	8
s%rvvy	9	;NN [[ 	2	1	3
5
5 [[VlJ%?@[[]VY,?@[[WsDk2$* 3 A A$*LArz   rE  c                       \ rS rSr\R
                  R                  S5        \R
                  R                  SS5      r\R
                  R                  SS5      r	SSS	S
\4SSS	S
\	4SSS	S
/ SQ/ SQ/ SQ/4SSS	S/ SQ/ SQ/ SQ/4SSSS/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/4SSSS/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S!Q/ S"Q/ S"Q/ S"Q/ S"Q/ S"Q/ S"Q/ S"Q/4S#S$SS/ S%Q/ S%Q/ S&Q/4S'S(SS/ S)Q/ S)Q/ S)Q/ S)Q/ S)Q/ S)Q/ S*Q/ S+Q/ S+Q/ S+Q/
4S,S-SS/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S!Q/ S"Q/ S"Q/ S"Q/ S"Q/ S"Q/ S"Q/4S.S/SS/ S0Q/ S0Q/ S1Q/ S2Q/4S3S4SS/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S Q/ S!Q/ S"Q/4/r
\R                  R                  S5\
5      S6 5       rS7S8SS/ S9Q/ S:Q/4S;S<SS/ S9Q/ S9Q/ S9Q/ S=Q/ S>Q/4S?S@SS/ SAQ/ SAQ/ SAQ/ SAQ/ SAQ/ SAQ/ SAQ/ SAQ/ SAQ/ SBQ/ SCQ/ SCQ/ SCQ/ SCQ/ SCQ/4/r\R                  R                  S5\
5      \R                  R!                  5       SD 5       5       rSE rSF rSG rSHrgI)JTestPageTrendTesti#  r   r2   r  r\      i2  g:hў?Fr  i  gsH?i,0  gY@?)r;  r9  I   r4  r9  `   r  rh  r
  r  r7  1   r6  +   rL  r9  r/  r/  r<  r  rX   r  r=  r~  r   )D   r  r9  "   rn	  r  A   X   rY   r6  r  r  r  C   E   r  r  r~  r  W   rL  rt  r   rr  rt  )r6  r_   U   r4  O   r^   \   V   rY   @   r   r  ru  rd   r   Y   r,  rt  rt  r  6   r_   B   r  r  i
  gXY?r  )r;   r   g @r4   r  r]   )r4   r3   r=   r\   r  rY   )r  rr
  r\   r^   rZ   r  iL  gs˜?T)r3   r2   r1   r   )r2   r3   r   r1   r     gĞ?)r2   r1   r   rd  r     g>K=?)r5   r4   r3   r2   r1   r   )r   r2   r3   r4   r1   r5   i  gqူ?)r4   r3   r2   r1   r   )r3   r   r2   r1   r4   r     ga?i  g;?)r6   r5   r4   r3   r2   r1   r   )r5   r4   r6   r3   r2   r1   r   ry  u   g[^6?zL, p, ranked, method, datac                     [         R                  R                  S5        [        R                  " XSUS9n[        XR                  5        [        X&R                  5        [        XFR                  5        g Nrm  )rankedr  
r   r  rn  ri   page_trend_testr   r*  r   r)  r  rn   LrT  r  r  r  r   s          rw   test_accuracyTestPageTrendTest.test_accuracy#  sH    
		r##DGQ&::&VZZ(rz   i  g-lpW?)
r\   r8   r7   r6   r5   r4   r3   r2   r1   r   )
r   r7   r3   r6   r5   r4   r8   r2   r1   r\   i*  gh[?)
r8   r1   r7   r6   r5   r4   r3   r2   r\   r   r9  i  g&]2?)r7   r6   r5   r4   r3   r2   r1   r   )r   r2   r4   r5   r3   r6   r1   r7   r  c                     [         R                  R                  S5        [        R                  " XSUS9n[        XR                  5        [        X&R                  5        [        XFR                  5        g r  r  r  s          rw   test_accuracy2 TestPageTrendTest.test_accuracy2#  sJ     			r##DGQ&::&VZZ(rz   c                 0   [         R                  R                  S5        Su  p[         R                  " SUS-   5      n[         R                  R	                  [         R                  " U5      5      n[         R                  R                  X5      n[        R                  " USS9n[        R                  " U5      n[        R                  " USS9n[        R                  " USS9n	[        R                  " XcS9n
[        R                  " US S 2U4   X4   S9n[        UR                  UR                  5        [        UR                  U	R                  5        [        UR                  U
R                  5        [        UR                  UR                  5        g )	Nrm  )r\   r  r   rV   Tr  F)predicted_ranks)r   r  rn  r   r  r|  ri   rankdatar  r   r*  )rn   r  r  r  permr  ranksr  r  r  res4res5s               rw   test_optionsTestPageTrendTest.test_options$  s   
		r))Aqs+yy$$RYYq\2yy~~a#t!,$$U+$$U48$$T%8$$UL$$U1d7^5D5JLT^^T^^4T^^T^^4T^^T^^4T^^T^^4rz   c                    [         R                  R                  S5        / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/n[         R                  " U5      R                  n[         R
                  " SS	5      n[        R                  " US
USS9n[        UR                  S5        [        UR                  SSS9  [        R                  " US
USS9n[        UR                  S5        [        UR                  SSS9  g )Nrm  )r  r  o   )r8  r  k   )g      y   )r0  r	  r_  )r0        )   r
  t   r   r6   Fr  )r  r  r  i  gy&1l?r3   rS  r  gHPsb?)r   r  rn  r   r  r   ri   r  r   r*  r   r)  )rn   r  r  r   s       rw   test_Ames_assay!TestPageTrendTest.test_Ames_assay$  s    
		r/Cxx~))Aq/##D4C+79 	S]]C(CJJ:##D4C+24 	S]]C(CJJ:rz   c                 v   [        [        SS9   [        R                  " S 5        S S S 5        [        [        SS9   [        R                  " / 5        S S S 5        [        [        SS9   [        R                  " SS/5        S S S 5        [        [        SS9   [        R                  " S///5        S S S 5        [        [        SS9   [        R                  " [        R
                  R                  SS5      5        S S S 5        [        [        SS9   [        R                  " [        R
                  R                  SS5      5        S S S 5        Sn[        [        US9   [        R                  " / SQ/ SQ// S	QS
9  S S S 5        [        [        US9   [        R                  " / SQ/ SQ// SQS
9  S S S 5        [        [        US9   [        R                  " / SQ/ SQ// SQS
9  S S S 5        [        [        US9   [        R                  " / SQ/ SQ/SS
9  S S S 5        [        [        SS9   [        R                  " / SQ/ SQ/S5        S S S 5        [        [        SS9   [        R                  " / SQ/ SQ/S5        S S S 5        [        [        SS9   [        R                  " / SQSS[        R                  //SS9  S S S 5        [        [        SS9   [        R                  " / SQ/ SQ/SS9  S S S 5        [        [        SS9   [        R                  " / SQ/ SQ/SS9  S S S 5        g ! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GNG= f! , (       d  f       GN#= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN{= f! , (       d  f       GNL= f! , (       d  f       GN,= f! , (       d  f       g = f)Nz`data` must be a 2d array.r   r   r1   zPage's L is only appropriater2   z+`predicted_ranks` must include each integerr  r  )r  r  )r  r1   r2   )r   r1   r2   r2   r  z`data` is not properly ranked)r   r1   r2   Tr  z`data` contains NaNsFr  z`method` must be inekki)r  r  z`ranked` must be boolean.)r  r  )	r   r   ri   r  r   r  r|  rm   r'  r&  s     rw   r  'TestPageTrendTest.test_input_validation*$  s   :-IJ!!$' K:-IJ!!"% K:-IJ!!1a&) K:-IJ!!QC5'* K :-KL!!"))..A"67 M:-KL!!"))..A"67 M @:W5!!	9'=2;= 6 :W5!!	9'=2=? 6 :W5!!	9'=2>@ 6 :W5!!	9'=2;= 6
 :-LM!!9i"8$? N:-LM!!9i"8$? N :-CD!!9q!RVVn"=).0 E :-BC!!	9'=)/1 D 9,GH!!	9'=)/1 IHW KJJJJJJJ MLLL
 65 65 65 65
 NMMM ED DC IHs   L.M )MM$5M65N NN,N><O.O""O4+PP	P*.
L= 
M
M!$
M36
N
N
N),
N;>
O
O"
O14
P
P
P'*
P8r   N)r   r   r   r   r   r  rn  r|  	data_3_25
data_10_26tsrP  r  r  r  ts2r]  r  r  r  r  r   r   rz   rw   ro  ro  #  s    IINN1		q"%IB'J $e\9
E%ulJ
G$e\===	>? %ug%#&() "D',l,l,l,()
 "D'y)Y	9y)Y	9y)Y	9y)-.
 "D' 24FGI"D'_o_o_o
 "D'y)Y	9y)Y	9y)Y	9
 !4!#8!#8:; "D'y)Y	9y)Y	CDO*
BX [[92>) ?) #T7,,./ $dG,.M,.M,./ $dG%'?%'?%'?%'?%'?%'?%'?%'(C* [[92>[[)  ?)5$;*/1rz   ro  iv5z	fun, argsc                     U " USS06nU " USS06n[        X#5        U R                   S3n[        R                  " [        [
        R                  " U5      S9   U " USSS.6  S S S 5        g ! , (       d  f       g = f)Nr  r  r  z#() got multiple values for argumentr   )r  r  )r   r   rP  r   r'  reescape)r+  r0  r   r  errs        rw   test_rename_mode_methodr  a$  si     t
$G
$C#7#Dll^>
?C	y		#	7T'0 
8	7	7s   
A++
A9c                       \ rS rSrS rS rS rS r\R                  R                  S/ SQ5      \R                  R                  SS	S
/5      S 5       5       r\R                  R                  SS	S
/5      S 5       rSrg)TestExpectileir$  c                     [         R                  R                  S5      nUR                  SS9n[        [        R
                  " USS9[         R                  " U5      5        g )Nrm  r  r  r:   r$  )r   r  r  r   ri   	expectilerl   rn   r  rp   s      rw   test_same_as_meanTestExpectile.test_same_as_means$  sC    ii##B'JJBJ5rwwqzBrz   c                     [         R                  R                  S5      nUR                  SS9n[        [        R
                  " USS9[         R                  " U5      5        g )Nrm  r  r  r   r  )r   r  r  r   ri   r  aminr  s      rw   test_minimumTestExpectile.test_minimumx$  C    ii##B'JJBJ3RWWQZ@rz   c                     [         R                  R                  S5      nUR                  SS9n[        [        R
                  " USS9[         R                  " U5      5        g )Nrm  r  r  r   r  )r   r  r  r   ri   r  amaxr  s      rw   test_maximumTestExpectile.test_maximum}$  r  rz   c                   ^	 [         R                  R                  S5      nS m	U	4S jnSnUR                  U5      nUR                  5       nUR                  U5      n[        R                  " XEUS9nU" XEU5      n[        Xx5        g )Nl   b@lN c                 ~    [         R                  " XS9nSU-
  XAU :*  '   [         R                  " XC-  X-
  S-  -  5      $ )Nr  r   r1   )r   r  rM  )r  r9  r$  r
  r  s        rw   r+  'TestExpectile.test_weights.<locals>.fun$  s;    Q1AE	A1fI66!+
233rz   c                    > [         R                  " U 5      [         R                  " U 5      4n[        R                  " TUXU4S9R
                  $ )N)bracketr0  )r   r  r  r   minimize_scalarrp   )r9  r$  r
  r  r+  s       rw   
expectile2.TestExpectile.test_weights.<locals>.expectile2$  sC    ffQi*G++C23G1DFFGaHrz   r\   r
  )r   r  r  ri   r  r   )
rn   r  r  r  r9  r$  r
  r   r  r+  s
            @rw   test_weightsTestExpectile.test_weights$  su    
 ii##$78	4
	H
 JJqM

**Q-ooa87+!rz   r$  )r  g?r:   g/#    ?rD  r  r  r%  c                    [         R                  R                  S5      nUR                  US9nS H4  n[	        [
        R                  " [         R                  " X%S9US9U5        M6     UR                  5       n[	        [
        R                  " XE-   US9[
        R                  " XAS9U-   5        [	        [
        R                  " XE-
  US9[
        R                  " XAS9U-
  5        [	        [
        R                  " XT-  US9U[
        R                  " XAS9-  5        UR                  USS9nUS:X  a  S	 nOUS:  a  S
 nOS nU" [
        R                  " [         R                  XF-      US9[
        R                  " XAS9[
        R                  " XaS9-   5        UR                  USS9n[
        R                  " XAS9[
        R                  " XaS9::  d   eUR                  USS9nS HZ  nU" [
        R                  " SU-
  U-  XV-  -   US9SU-
  [
        R                  " XAS9-  U[
        R                  " XaS9-  -   5        M\     [	        [
        R                  " U* US9[
        R                  " USU-
  S9* 5        g)ub  
See Section 6 of
I. Steinwart, C. Pasin, R.C. Williamson & S. Zhang (2014).
"Elicitation and Identification of Properties". COLT.
http://proceedings.mlr.press/v35/steinwart14.html

and

Propositions 5, 6, 7 of
F. Bellini, B. Klar, and A. Müller and E. Rosazza Gianin (2013).
"Generalized Quantiles as Risk Measures"
http://doi.org/10.2139/ssrn.2225751
rm  r  )r  r   r:   )r  r  r  r\   r{  r:   c                     [        X5        g r  )r   r9  rE  s     rw   	assert_op:TestExpectile.test_expectile_properties.<locals>.assert_op$  s
    %rz   c                     X:  d   eg r  r   r  s     rw   r  r  $      uurz   c                     X:  d   eg r  r   r  s     rw   r  r  $  r  rz   r4   )r1  r:   rD  r   N)r   r  r  r  r   ri   r  r   exponentiallogisticr_)rn   r$  r  r  rp   rY  rq   r  s           rw   test_expectile_properties'TestExpectile.test_expectile_properties$  s'   $ ii##B'JJAJ
 Aa >eL  OOOOAE/OOA+a/	
 	OOAE/OOA+a/	
 	OOAE///	
 LLaRL(C<& S[ 	OOBEE!%L6OOA+ooa-.	
 JJA1J%OOA+uq/NN	
N LLaRL( A1a!#U;177EOOA334 ! 	OOQBe,__Qag..	
rz   c                    [         R                  R                  S5      nUR                  SUS9n/ n[         R                  " S[         R
                  " S5      S5      n[         R                  SUSUS S	S	2   -
  S4    H&  nUR                  [        R                  " X6S
95        M(     [         R                  " [         R                  " U5      S:  5      (       d   eg )Nrm  r1   )r9  r  r  r:   r  r   r   rb   r  )r   r  r  paretologspacelog10r  r6  ri   r  rc  diff)rn   r  r  rp   e_list	alpha_seqr$  s          rw   test_monotonicity_in_alpha(TestExpectile.test_monotonicity_in_alpha%  s    ii##B'JJJ#KKRXXc]C8	UU1iYv2v->)>ABEMM%//!9: Cvvbggfo)****rz   r   N)r   r   r   r   r  r  r  r  rP  r  r  r  r  r   r   rz   rw   r  r  r$  s    C
A
A
"4 [[: [[S2t*-_
 ._
B [[S2t*-+ .+rz   r  c            	       h   \ rS rSr/ SQrS/ SQ\R                  \R                  S/rS r	\
S 5       r\R                  R                  S\S	S
/ / SQ//-   5      S 5       r\R                  R                  S\5      S 5       r\R                  R                  S\5      S 5       r\R                  R                  S\5      S 5       r\R                  R                  SSS/ SQ/5      \R                  R                  SSS/5      \R                  R                  SSS/5      S 5       5       5       rS rSrg)TestLMomenti%  )yףp=
?r  p=
ף?r;   ru
  r  r;   r:   r   rk  rs
  {Gz?g@(\?gףp=
?
ףp=
?g)\(?gRQ @rm  {Gz?ffffff @r  g{Gz@gRQ?gGz@gQ?(\?r  gzG?g
ףp=
?gQ?ffffff?gGz
@g(\?g(\?gQ?q=
ףp?g(\@Q?gGz	@r  Q?r  p=
ף @r  gp=
ף@gq=
ףp@gRQ?Gz?g
ףp=
?r2  gHzG?g      @r  gQ?r  r  RQ?r  gQ?p=
ף?gQ@gGz?gQ?gp=
ף?q=
ףp?rv
  gp=
ף?gQ?r  r  g@r  g)\( @gzG@r  r  gGz?g(\?r  333333?)\(?rk  r  gGz@rD  g(\?g=
ףp=?r  r  gHzG?{Gz?r  g
ףp=
?gףp=
?r  r  r  gQ?r	  g?r  r  g(\?r  gQ?gffffff@gQ?g?r  gGz?r  g{Gz?gHzG@r  r  r  g\(\?g(\?r  g(\?r;   )r   r1   r=   za duckc                     Sn[         R                  " [        US9   [        R                  " [
        R                  " U R                  [
        R                  S95        S S S 5        g ! , (       d  f       g = fNz*`sample` must be an array of real numbers.r   rZ  )	rP  r   r   ri   lmomentr   r   r  rw  r&  s     rw   test_dtype_ivTestLMoment.test_dtype_iv%  s@    >]]:W5MM"((499BMMBC 655s   AA''
A5c                     Sn[         R                  " [        US9   [        R                  " [
        R                  " U R                  [        S95        S S S 5        g ! , (       d  f       g = fr  )	rP  r   r   ri   r  r   r   r  r<  r&  s     rw   test_dtype_iv_non_numeric%TestLMoment.test_dtype_iv_non_numeric"%  s<    >]]:W5MM"((499F;< 655s   8A
A+rp  r   rb   r  c                     Sn[         R                  " [        US9   [        R                  " U R
                  US9  S S S 5        g ! , (       d  f       g = f)Nz*`order` must be a scalar or a non-empty...r   ry  rP  r   r   ri   r  r  )rn   rp  r  s      rw   test_order_ivTestLMoment.test_order_iv(%  s3    >]]:W5MM$))51 655    A
ArW   c                     Sn[         R                  " [        US9   [        R                  " U R
                  US9  S S S 5        g ! , (       d  f       g = f)Nz"`axis` must be an integer, a tupler   rV   r  )rn   rW   r  s      rw   test_axis_ivTestLMoment.test_axis_iv.%  s3    6]]:W5MM$))$/ 655r	  sortedc                     Sn[         R                  " [        US9   [        R                  " U R
                  US9  S S S 5        g ! , (       d  f       g = f)Nz`sorted` must be True or False.r   )r  r  )rn   r  r  s      rw   test_sorted_ivTestLMoment.test_sorted_iv4%  s3    3]]:W5MM$))F3 655r	  standardizec                     Sn[         R                  " [        US9   [        R                  " U R
                  US9  S S S 5        g ! , (       d  f       g = f)Nz$`standardize` must be True or False.r   )r  r  )rn   r  r  s      rw   test_standardize_ivTestLMoment.test_standardize_iv:%  s3    8]]:W5MM$))= 655r	  r   r3   r  FTc                 >   [         R                  " / SQ5      nU(       d  USS === US   -  sss& U(       a   [         R                  " U R                  5      OU R                  n[        R
                  " XQX#S9n[        Xd[         R                  " U5      S-
     5        g )N)g0ʻEH?gk?gz[?g+3 ?r1   r   )r  r  )r   rf   r  r  ri   r  r   )rn   rp  r  r  r  r  r   s          rw   test_lmomentTestLMoment.test_lmoment@%  sw     jj B C Gs1vG%+rwwtyy!mmD[PE!21!456rz   c                    [         R                  n[         R                  " U R                  5      n[        R
                  " UR                  U5      5      n[        R
                  " U5      nUR                  R                  U:X  d   e[        X4SS9  [         R                  n[         R                  " / SQ5      n[        R
                  " UR                  U5      5      n[        R
                  " UR                  [         R                  5      5      nUR                  R                  [         R                  :X  d   e[        X4SS9  g )Nr  r  r  r2  )r   r   rf   r  ri   r  r  rX  r  r   int64r   )rn   rX  sampler   r  s        rw   
test_dtypeTestLMoment.test_dtypeT%  s    

DII&mmFMM%01mmF#yy~~&&&t,O,mmFMM%01mmFMM"**56yy~~+++u-rz   r   N)r   r   r   r   r  r   rm   r  not_integersr   r(   r  rP  r  r  r  r  r  r  r  r  r   r   rz   rw   r  r  %  sN   
ND bffbffh?LD
 = =
 [[WlaR)5M&MN2 O2
 [[V\20 30
 [[X|44 54
 [[]L9> :>
 [[Wq!\&:;[[]UDM:[[Xt}57 6 ; <7".rz   r  c                   
   \ rS rSr\R
                  R                  S/ SQ5      \R
                  R                  SSS/5      \R
                  R                  SSS/5      S	 5       5       5       rS
 rS r	S r
S rS rS rS rSrg)TestXP_Meanid%  rW   Nr   rb   )rQ  r1   r
  NTr  Fc                    [         R                  R                  S5      nUR                  S5      nUR                  U5      nS =pU(       a:  UR                  S5      nUR                  U5      n	[         R                  " Xh5      u  ph[        XyX$S9n
[         R                  " XhX$S9n[        XR                  U5      5        g )N   -fH r  r   )r
  rW   r  )r   r  r  rf   rx  r#   r&  r/   )rn   ro   rW   r
  r  r  rp   x_xpr  w_xpr   r  s               rw   test_xp_mean_basicTestXP_Mean.test_xp_mean_basicf%  s     ii##N3JJy!zz!}

6"A::a=D&&q,DAtHjjDDZZ_-rz   c                     UR                  S5      UR                  S5      p2Sn[        R                  " [        US9   [        X#S9  S S S 5        g ! , (       d  f       g = f)Nr   r4   z/Array shapes are incompatible for broadcasting.r   r
  )r   rH  rP  r   r   r#   )rn   ro   rp   r  r  s        rw   test_non_broadcastable"TestXP_Mean.test_non_broadcastabley%  s@    yy~rxx{1C]]:W5Q" 655s   
A
Ac                    UR                  / SQ5      n[        UR                  / SQ5      US9n[        X1R                  UR                  5      5        [        UR                  / SQ5      US9n[        X1R                  [        R
                  * 5      5        [        UR                  / SQ5      US9n[        X1R                  [        R
                  5      5        g )Nr  r  r
  )rm  r   r   )r   r   rm  )rf   r#   r/   rm   r   r  )rn   ro   r
  r   s       rw   test_special_casesTestXP_Mean.test_special_cases%  s    **]+rzz,/AZZ/0rzz,/AZZ01rzz,/AZZ/0rz   c                    UR                  S5      nUS:H  nUR                  X1R                  UR                  5      U5      nSn[        R
                  " [        US9   [        USS9  S S S 5        [        U5      n[        USS9nUR                  UR                  5      n[        XW5        [        Xg5        [        USS9nUR                  X#)    5      n[        X5        UR                  S	5      n	UR                  X1R                  UR                  5      U	5      n	[        UR                  S5      U	SS
9nUR                  X#)    5      n[        X5        Sn[        R                  " [        US9   [        U[        R                  -  SS9nUR                  UR                  5      n[        X5        S S S 5        g ! , (       d  f       GNY= f! , (       d  f       g = f)Nr   r2   r   r   r   r   r  r   r\   )r
  r   After omitting NaNs...)r   rP  rf   rm   rP  r   r   r#   r0   rl   r/   r  rQ  r   r   )
rn   ro   rp   r  r  r  r  r  r   r
  s
             rw   ry  TestXP_Mean.test_nan_policy%  ss   IIcNQHHT::bff-q1 2]]:W5Q7+ 6 {k2jj "" qV,ggah! ''"+((4BFF!3W=ryy~w6Jggah! +\\.81rvv:&9C**RVV$CC% 981 650 98s   F:/AG:
G	
Gc                 F   Sn[         R                  " [        US9   [        UR	                  / 5      5      nUR	                  UR
                  5      n[        X45        S S S 5        Sn[         R                  " [        US9   [        UR	                  / /5      SS9nUR	                  UR
                  /5      n[        X45        S S S 5        [        UR	                  / /5      SS9nUR	                  / 5      n[        X45        g ! , (       d  f       N= f! , (       d  f       NV= fNz,One or more sample arguments is too small...r   z2All axis-slices of one or more sample arguments...r   rV   r   )rP  rQ  r   r#   rf   rm   r0   rn   ro   r  r   r  s        rw   r  TestXP_Mean.test_empty%  s    @\\,G<2::b>*C**RVV$CC% =
 G\\,G<2::rd+!4C**bffX&CC% =
 rzz2$'a0jjn! =< =<   AD AD
D
D c           	         UR                  UR                  5      R                  n[        R                  " X"/[        R                  S9nUR	                  U5      n[        R
                  " SS9   [        U5      n[        R                  " U5      n[        R                  R                  U[        R                  5        [        XQR	                  U5      5        S S S 5        [        XAR                  S9nUR	                  [        R                  " [        R                  " U[        R                  S95      5      n[        XV5        g ! , (       d  f       Ns= f)NrZ  r}  over)r   r   r  r   rf   r  r#   rl   r  r   r  r/   r   rn   ro   r  x_npr#  r   r  s          rw   r  TestXP_Mean.test_dtype%  s    hhrzz"&&zz3*BJJ7zz$ [[h'4.C''$-CJJ##C0CC1	 ( t::.jjD

!CDE! ('s   /A*E
Ec                     UR                  S5      nUR                  S5      n[        [        U5      [        U5      5        [        [        X2S9[        X3S95        g )Nr\   r   r
  )r   r0   r#   rn   ro   rp   rq   s       rw   test_integerTestXP_Mean.test_integer%  sB    IIbMIIcNXa[1.0FGrz   c                 @   [         R                  R                  S5      nUR                  S5      u  p4pV[        UR	                  X4S-  -   5      UR	                  XVS-  -   5      S9n[         R
                  " X4S-  -   XVS-  -   S9n[        XqR	                  U5      5        g )Nr"  )r3   r  r  r
  )r   r  r  r#   rf   r&  r/   )	rn   ro   r  rp   rq   wxwyr   r  s	            rw   r   TestXP_Mean.test_complex_gh22404%  s~    ii##N3zz'*brzz!d(+RZZU
5KLjjrT22:6ZZ_-rz   r   )r   r   r   r   rP  r  r  r%  r(  r+  ry  r  r  r=  r  r   r   rz   rw   r  r  d%  s    [[V%;<[[Yt5[[Z%7. 8 6 =. #1"&H""""H.rz   r  r/  c                      \ rS rSr\R
                  R                  S/ SQ5      \R
                  R                  SSS/5      \R
                  R                  SSS	/5      \R
                  R                  S
SS/5      S 5       5       5       5       rS rS r	S r
S rS r\R
                  R                  SSS9S 5       rSrg)
TestXP_Vari%  rW   r   r  FTr   r   r   r   r  r   c                    [         R                  R                  S5      nUR                  S5      n[         R                  nUS:X  a>  UR                  UR                  S9S:  n	[         R
                  Xy'   [         R                  nUR                  U5      n
[        XX4US9n[        5        nUR                  [        S5        U" XrX4S9nS S S 5        [        XR                  W5      5        g ! , (       d  f       N)= f)	Nr"  r  r   r  r:   )rW   r  r   r   r  )rW   r  rN  )r   r  r  r   r  rm   nanvarrf   r$   r   r   r   r/   )rn   ro   rW   r  r   r   r  rp   var_refnan_maskr#  r   r   r  s                 rw   test_xp_var_basicTestXP_Var.test_xp_var_basic%  s    
 ii##N3JJy!&&zzqwwz/#5H&&AKiiGzz!}d!+-  CJJ~'JK!KC ! 	ZZ_-	 ! s   +C,,
C:c                     [        UR                  SS/5      SS9n[        X!R                  UR                  5      5        g )Nr   rm  r2   r~   )r$   rf   r/   rm   )rn   ro   r   s      rw   r+  TestXP_Var.test_special_cases%  s0    bjj"b*q9ZZ/0rz   c                    UR                  S5      nUS:H  nUR                  X1R                  UR                  5      U5      nSn[        R
                  " [        US9   [        USS9  S S S 5        [        U5      n[        USS9nUR                  UR                  5      n[        XW5        [        Xg5        [        USS9n[        U5      n	U	R                  X#)    5      n[        X5        S	n[        R                  " [        US9   [        U[        R                  -  SS9nUR                  UR                  5      n[        X5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)
Nr   r2   r   r   r   r   r  r   r.  )r   rP  rf   rm   rP  r   r   r$   r0   r)   r   r/   rQ  r   r   )
rn   ro   rp   r  r  r  r  r  r   r   s
             rw   ry  TestXP_Var.test_nan_policy&  s!   IIcNQHHT::bff-q1 2]]:W5A'* 6 qzq[1jj "" aF+!!$kk!E(#! +\\.8!bff*8C**RVV$CC% 98% 65$ 98s   EAE!
E!
E/c                 F   Sn[         R                  " [        US9   [        UR	                  / 5      5      nUR	                  UR
                  5      n[        X45        S S S 5        Sn[         R                  " [        US9   [        UR	                  / /5      SS9nUR	                  UR
                  /5      n[        X45        S S S 5        [        UR	                  / /5      SS9nUR	                  / 5      n[        X45        g ! , (       d  f       N= f! , (       d  f       NV= fr1  )rP  rQ  r   r$   rf   rm   r0   r2  s        rw   r  TestXP_Var.test_empty"&  s    @\\,G<"**R.)C**RVV$CC% =
 G\\,G<"**bT*3C**bffX&CC% =
 bjj"&Q/jjn! =< =<r4  c           	         UR                  UR                  5      R                  n[        R                  " X"S-  /[        R                  S9nUR	                  U5      n[        R
                  " SS9   [        U5      n[        R                  " U5      n[        R                  R                  U[        R                  5        [        XQR	                  U5      5        S S S 5        [        XAR                  S9nUR	                  [        R                  " [        R                  " U[        R                  S95      5      n[        XV5        g ! , (       d  f       Ns= f)Nr1   rZ  r}  r6  )r   r   r  r   rf   r  r$   r   r  r   r  r/   r   r8  s          rw   r  TestXP_Var.test_dtype3&  s    hhrzz"&&zz3A,bjj9zz$ [[h'$-C&&,CJJ##C0CC1	 ( d**-jj

4rzz BCD! ('s   2A*E		
Ec                     UR                  S5      nUR                  S5      n[        [        U5      [        U5      5        g )Nr\   r   )r   r0   r$   r<  s       rw   r=  TestXP_Var.test_integerD&  s.    IIbMIIcN
GAJ/rz   rG   r  rE   c                    [         R                  R                  S5      nUR                  S5      u  p4[        UR	                  X4S-  -   5      5      n[         R
                  " X4S-  -   5      n[        XQR	                  U5      SS9  g )Nr"  )r1   r  r  F)check_dtype)r   r  r  r$   rf   r   r/   )rn   ro   r  rp   rq   r   r  s          rw   r  TestXP_Var.test_complex_gh22404J&  se    ii##N3zz'"bjjrT*+ffQ2XZZ_%@rz   r   N)r   r   r   r   rP  r  r  rI  r+  ry  r  r  r=  rH   r  r   r   rz   rw   rD  rD  %  s     [[V%;<[[Z%7[[\Aq62[[\K+@A. B 3 8 =.*1
&<""""0 [[!!"4=R!SA TArz   rD  c           	         [         R                  R                  S5      nUR                  SS9nU R                  U5      nSn[	        X4U S9u  pV[        XPR                  U5      5        [        Xd5        S n[	        X4U S9u  pV[        XPR                  UR                  5       5      5        [        US5        Sn[	        US   X@S9u  pV[        XPR                  [         R                  " US   5      5      5        [        Xd5        g )	Nl   ~Mr  r  r   r
  r   r1   rq  )	r   r  r  rf   r    r0   r   r  
atleast_1d)ro   r  r  rp   rW   x_outaxis_outs          rw   test_chk_asarrayr\  S&  s    
))


.C		#B


2AD"1B7OEE::b>* D"1B7OEE::bhhj121D"1W:D@OEE::bmmBwK&@AB rz   numpyz,These parameters *are* compatible with NumPyc                 N   U R                  / SQ5      nSn[        R                  " [        US9   [        R
                  " USS9  S S S 5        [        R                  " [        US9   [        R
                  " USS9  S S S 5        g ! , (       d  f       NF= f! , (       d  f       g = f)Nr  r
  r   r   r   Tr  )rf   rP  r   r  ri   r  )ro   rp   r  s      rw   'test_axis_nan_policy_keepdims_nanpolicyr_  i&  sn     	

< A5G	*'	:

1( 
;	*'	:

1t$ 
;	: 
;	:	:	:s   B&B
B
B$r-  )r   r  r  rP  collectionsr   	itertoolsr   hypothesis.extra.numpyextrar]  r  r  r  numpy.testingr   r   r   r   r	   r
   r   r   r   rP  r   r   numpy.ma.testutilsrc  	testutilsr  r   r   r   r   r   scipy.statsri   scipy.stats.mstatsr  scipy.stats._mstats_basic_mstats_basicro  scipy.stats._ksstatsr   scipy.special._testutilsr   scipy.specialr   scipyr   common_testsr   scipy.stats._axis_nan_policyr   r   r   r   r   r   r  r   r    r!   r"   r#   r$   r%   scipy._lib._utilr&   scipy.conftestr'   r(   scipy._lib._array_apir)   r*   r+   r,   r-   r.   scipy._lib._array_api_no_0dr/   r0   r  rH   r  rg   r  r   r   r   r   r   r  rJ   r   r#  r  r`  r  rk  rq  rw  r~  r  r  r  r  r  r  r  r  r  r  r  r  rE  rX  r  r  r  rZ  r  r  r  r  	compositer  r  r-  PowerDivCaser  r  r  r  rs  r  r  r  r  r  r5  r  r  r  r  rC  r  r  r  r  r  r  r  r  r  r  r  r  rC	  rb	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r]  r	  r	  r	  r	  r	  r
  r
  r'
  r*
  r8
  rQ
  rx
  r
  r
  r
  r
  r
  r
  r
  r  r0  rd  rw  r  r  r  r  r  rO  ru  r  r  r  r  r  rE  ro  r  r  r  rp   rq   wilcoxonr  rG  r  r7  r  r  r  r  r  rD  r\  r_  r   rz   rw   <module>rx     sP   
 	  "  % %  . . .
  *     / /   # # 0 0 ( -   -T TU U U & DG G H;;//  

u% %(  !&(	 238
:DeLDeL3U; +&JK$P +,rT rT -	 L rTjp# p#f +,4 N> N> ! - N>bDL DLN{6 {6|~5 ~5VW3t4 <3$SE SElW2t&&$R+ +(V# V#r0D)3"rN rNjf3 f3R *E *E *EZ +,+&DEW" W" F - W"t<@ <@~1f@ f@Rs" s"l= =x" x"vg"# g"T    !< t%@  B+,F) F)  -BF)Rp> p>f & }Dqt"&&+266$<78AbffSkMAbffTlN:;I	K }N"&&+"&&,6266#;FGAbffSkMBrvvd|O;asmKL1	2 }AAD"&&+266$<78AbffSkMAbffTlN:;I	K |<aaQa1+ : r!!Qa1
 rxxBr
+--!!" rxxBr
+!!# 4 F< F< F<R (' (' ('V S# S# S#l4Dn+( +(`Z. Z.~c. c.L	rEj1*+ ,88I.788I.79:0:0
. (HI J. ) ,,ryy}a.@A ??RYYr]BIIbM,JKMN5N5
/d 
/ t%@  B+,Q% -B Q%h7At DEO7 O7 FO7d
 DEF5 F5 FF5RT7 T7n t%@  B+,HB HB -B HBVL$ t%@  B+,N' -B N'b t%@  B+,5 -B 5* , % % &!12+,,88I.788I.79:0:  - 30  
& 
& & & d%I  K+,G -K G t%@  B+,% -B % t%@  B+,G -B G8% t%@  B+,9>  -B 
9>x d%O  Q+,  -Q, t%@  B+,%  -B%<V+ V+r <- <- <-|"> ":/&~ /&d:^ :
A A. :1 :1 :1z{- {-|1"(>V 15D+ DDD o3 o3 o3d f3 f3 f3R wW wW wWtP- P-f(.90[;|T7 T7n,/ ,/^i) i)Xz) z)zX Xv 4$k2.0 +,c4 c4  -	0c4L#A #ALl  l ^[ [|@ @Fi iXHA HAV{1 {1| 	iiI&JJrNJJrN  >>A40 >>Auzz~~+>? >>Aq62 <<!Q011X+ X+vT. T.n z. z. z.z +,+&QRkA kA S - kA\ ! !* g%S  U+,
%  -U
%rz   