+
    ,i2                     .   ^ RI t ^ RIt^ RIHt ^ RIt^ RIHt ^ RIH	t	H
t
 ^ RIHtHtHt ]P                  P                   t]P                  P!                  RRR7       ! R	 R
4      4       t]P                  P!                  RRR7       ! R R4      4       tR# )    N)raises)stats)normexpon)xp_assert_closexp_assert_equalxp_assert_lessz
dask.arrayzboolean index assignmentreasonc                   z   a  ] tR t^t o R tR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tRtV tR# )TestEntropyc                   VP                  . RO4      pVP                  . RO4      p\        P                  ! W"4      p\        P                  ! W#4      p\        WAP                  R4      4       \	        V) VP                  R4      4       R# )      ?        N)r   皙?333333?)皙?g      ?g?)asarrayr   entropyr   r	   )selfxppkqkeselfedoubles   &&    @/usr/lib/python3/dist-packages/scipy/stats/tests/test_entropy.pytest_entropy_positive!TestEntropy.test_entropy_positive   s_    ZZ(ZZ)*b%--'zz"~.xB0    c                   VP                  ^4      p\        P                  ! VRR7      p\        VP	                  VR,
          4      VP                  R4      4       VP                  ^4      pVP                  VP                  ^4      ^8  RV4      p\        P                  ! W$4      p\        P                  ! W$RR7      p\        VP	                  W5,          \        P                  ! R4      ,
          4      VP                  R4      4       R# )          @baseg      @gh㈵>N)
onesr   r   r	   absr   wherearangemathlog)r   r   r   Sr   S2s   &&    r   test_entropy_baseTestEntropy.test_entropy_base   s    WWR[MM"2&rvva"f~rzz%'89WWR[XXbiima'R0MM"!]]2+rvvadTXXb\12BJJu4EFr   c                    VP                  . RO4      p\        \        P                  ! V4      VP                  R4      4       R# )r   g R^?N)r         ?r"   r   r   r   r   )r   r   xs   && r   test_entropy_zeroTestEntropy.test_entropy_zero$   s0    JJ|$a(

#67	9r   c                    VP                  R R.RR.RR..4      pVP                  RR .RR.RR..4      p\        \        P                  ! W#4      VP                  RR.4      4       R# )r   r   333333?r   r   gN!0?2?Nr1   r   r   r   r   s   &&  r   test_entropy_2dTestEntropy.test_entropy_2d*   sh    ZZ#sc3Z#s<=ZZ#sc3Z#s<=b-

Iz#:;	=r   c                z   VP                  R R.RR.RR..4      pVP                  RR .RR.RR..4      p\        \        P                  ! W#4      VP                  VP                  R.4      4       VP                  RR.RR.RR..4      p\        \        P                  ! W#4      VP                  RR.4      4       R# )	r   r   r6   r   r   r   r7   g^fTF?N)r   r   r   r   infr8   s   &&  r   test_entropy_2d_zero TestEntropy.test_entropy_2d_zero0   s    ZZ#sc3Z#s<=ZZ#sc3Z#s<=b-

BFFJ#78	: ZZ#sc3Z#s<=b-

J
#;<	>r   c                    VP                  R R.RR.RR..4      p\        \        P                  ! V^R7      VP                  . RO4      4       R# )r   r   r6   r   r   axisN)R^?rB   gD%+?r1   r   r   r   s   && r   $test_entropy_base_2d_nondefault_axis0TestEntropy.test_entropy_base_2d_nondefault_axis:   sF    ZZ#sc3Z#s<=bq1

#GH	Jr   c                    VP                  R R.RR.RR..4      pVP                  RR .RR.RR..4      p\        \        P                  ! W#^R7      VP                  . RO4      4       R# )r   r   r6   r   r   r@   N){[<?rG   gC8X?r1   r8   s   &&  r   test_entropy_2d_nondefault_axis+TestEntropy.test_entropy_2d_nondefault_axis?   sg    ZZ#sc3Z#s<=ZZ#sc3Z#s<=b15

#GH	Jr   c                   VP                  R R.RR.RR..4      pVP                  R R.RR..4      pRp\        P                  ! \        VR7      ;_uu_ 4        \        P
                  ! W#4       RRR4       R#   + '       g   i     R# ; i)r   r   r6   r   r   /Array shapes are incompatible for broadcasting.matchN)r   pytestr   
ValueErrorr   r   )r   r   r   r   messages   &&   r   test_entropy_raises_value_error+TestEntropy.test_entropy_raises_value_errorE   so    ZZ#sc3Z#s<=ZZ#sc3Z01C]]:W55MM"! 6555s   A99B
	c                    VP                  R R.RR.RR..4      p\        \        P                  ! V^ R7      \        P                  ! V4      4       R# r   r   r6   r   r   r@   Nr1   rC   s   && r   1test_base_entropy_with_axis_0_is_equal_to_default=TestEntropy.test_base_entropy_with_axis_0_is_equal_to_defaultL   sD    ZZ#sc3Z#s<=bq1b)	+r   c                    VP                  R R.RR.RR..4      pVP                  RR .RR.RR..4      p\        \        P                  ! W#^ R7      \        P                  ! W#4      4       R# rT   r1   r8   s   &&  r   ,test_entropy_with_axis_0_is_equal_to_default8TestEntropy.test_entropy_with_axis_0_is_equal_to_defaultQ   se    ZZ#sc3Z#s<=ZZ#sc3Z#s<=b15b-	/r   c                    VP                  R R.RR.RR..4      p\        \        P                  ! VP                  4      \        P                  ! V^R7      4       R# rT   r   r   r   r   TrC   s   && r   test_base_entropy_transposed(TestEntropy.test_base_entropy_transposedW   sH    ZZ#sc3Z#s<=bdd+bq1	3r   c           	        VP                  R R.RR.RR..4      pVP                  RR .RR.RR..4      p\        \        P                  ! VP                  VP                  4      \        P                  ! W#^R7      4       R# rT   r[   r8   s   &&  r   test_entropy_transposed#TestEntropy.test_entropy_transposed\   so    ZZ#sc3Z#s<=ZZ#sc3Z#s<=bddBDD1b15	7r   c                   \         P                  P                  R 4      pVP                  VP                  ^4      4      pVP                  VP                  R4      4      p\        P
                  ! W4RR7      p\        V^ ,          \        P
                  ! W4R,          4      4       \        V^,          \        P
                  ! W4R,          4      4       R# )l   @UC<r@   N)      )r   .)rd   .)nprandomdefault_rngr   r   r   r   )r   r   rngr2   yress   &&    r   test_entropy_broadcasting%TestEntropy.test_entropy_broadcastingb   s    ii##$56JJszz!}%JJszz&)*mmAr*Aa6 ;<Aa6 ;<r   c                    VP                  R4      pVP                  R4      pRp\        P                  ! \        VR7      ;_uu_ 4        \        P
                  ! W#4       RRR4       R#   + '       g   i     R# ; i)
   rK   rL   N)ro   rd      )   rc   r%   rN   r   rO   r   r   )r   r   r2   rj   rP   s   &&   r   test_entropy_shape_mismatch'TestEntropy.test_entropy_shape_mismatchj   sO    GGK GGGC]]:W55MM! 6555s   	A**A;	c                    VP                  ^
4      pRp\        P                  ! \        VR7      ;_uu_ 4        \        P
                  ! VRR7       RRR4       R#   + '       g   i     R# ; i)ro   z!`base` must be a positive number.rL   r#   Nrr   r   r   r2   rP   s   &&  r   test_input_validation!TestEntropy.test_input_validationq   sB    GGBK5]]:W55MM!"% 6555s   AA,	 N)__name__
__module____qualname____firstlineno__r   r-   r3   r9   r=   rD   rH   rQ   rU   rX   r]   r`   rl   rs   rx   __static_attributes____classdictcell____classdict__s   @r   r   r      sX     1	G9=>J
J"+
/3
7= & &r   r   c                     a  ] tR t^xt o RtR tR tR tR tR t	R t
]P                  P                  RR	R
R]P                  ! R]! RRR7      R7      .4      R 4       tR	RR
RRRRR/tR	RR
RRR RR!/t]]]]/t]P                  P                  RR	R
R]P                  ! R]! RRR7      R7      .4      ]P                  P                  R]].4      R 4       4       t]P                  P                  R. R"O4      R 4       t]P                  P                  RR	R
]P                  ! R]! RRR7      R7      R.4      ]P                  P                  R. R#O4      R 4       4       tRtV tR# )$TestDifferentialEntropyz
Vasicek results are compared with the R package vsgoftest.

# library(vsgoftest)
#
# samp <- c(<values>)
# entropy.estimate(x = samp, window = <window_length>)

c                   \         P                  P                  ^ 4      pVP                  ^d4      pVP	                  VP                  4       4      p\        P                  ! VRR7      p\        WAP	                  R4      4       \        P                  ! V^RR7      p\        WAP	                  R4      4       \        P                  ! V^RR7      p\        WAP	                  R4      4       R# )r   vasicekmethod- {?)window_lengthr    ?=&?N	rf   rg   RandomStatestandard_normalr   tolistr   differential_entropyr   )r   r   random_statevaluesr   s   &&   r   !test_differential_entropy_vasicek9TestDifferentialEntropy.test_differential_entropy_vasicek   s    yy,,Q/--c2FMMO,,,VIF,=!>?,,V14=?,=!>?,,V14=?,=!>?r   c                   \         P                  P                  ^ 4      pVP                  R4      pVP	                  VP                  4       4      p\        P                  ! V^RR7      pVP	                  . RO4      p\        WE4       \        P                  ! V^^RR7      pVP	                  . RO4      p\        WE4       \        P                  ! V^^RR7      pVP	                  . RO4      p\        WE4       R# )	r   r   )rA   r   )rA   r   r   N   d   )r   gUZdpx?gE7L?)r   gzG?gt?)r   gl+ɍj?go4d?r   )r   r   r   r   r   refs   &&    r   4test_differential_entropy_vasicek_2d_nondefault_axisLTestDifferentialEntropy.test_differential_entropy_vasicek_2d_nondefault_axis   s    yy,,Q/--h7FMMO,,,V!INjjRS%,,V!14=?jjQR%,,V!14=?jjRS%r   c           	        \         P                  P                  ^ 4      pVP                  R4      pVP	                  VP                  4       4      pRpVP                  ^,          pR^ V^,          V0 FQ  pVP                  VVR7      p\        \        VR7      ;_uu_ 4        \        P                  ! VV^R7       RRR4       KS  	  R#   + '       g   i     Kh  ; i)r   zhWindow length \({window_length}\) must be positive and less than half the sample size \({sample_size}\).)r   sample_sizerL   )r   rA   Nr   re   )rf   rg   r   r   r   r   shapeformatassert_raisesrO   r   r   )r   r   r   r   	error_strr   r   formatted_error_strs   &&      r   ,test_differential_entropy_raises_value_errorDTestDifferentialEntropy.test_differential_entropy_raises_value_error   s    yy,,Q/--h7FMMO,< 	
 ll1o ![!^[AM"+"2"2+' #3 #
 z1DEE**"/ FE B FEEs   !C		Cc                   \         P                  P                  ^ 4      pVP                  R4      pVP	                  VP                  4       4      p\        P                  ! V^ R7      p\        P                  ! V4      p\        WE4       R# )r   r@   N)r   r   r   )r   r   r   r   r   default_entropys   &&    r   >test_base_differential_entropy_with_axis_0_is_equal_to_defaultVTestDifferentialEntropy.test_base_differential_entropy_with_axis_0_is_equal_to_default   sd    yy,,Q/--h7FMMO,,,V!<44V<1r   c                $   \         P                  P                  ^ 4      pVP                  R4      pVP	                  VP                  4       4      p\        \        P                  ! VP                  4      \        P                  ! V^R7      4       R# )r   r@   Nr   )
rf   rg   r   r   r   r   r   r   r   r\   )r   r   r   r   s   &&  r   )test_base_differential_entropy_transposedATestDifferentialEntropy.test_base_differential_entropy_transposed   sd    yy,,Q/--h7FMMO,&&vxx0&&vA6	
r   c                   \         P                  P                  ^
4      pVP                  VP	                  4       4      pRp\
        P                  ! \        VR7      ;_uu_ 4        \        P                  ! VRR7       RRR4       Rp\
        P                  ! \        VR7      ;_uu_ 4        \        P                  ! VRR7       RRR4       R#   + '       g   i     LY; i  + '       g   i     R# ; i)	ro   z+`base` must be a positive number or `None`.rL   r#   Nz`method` must be one of...z	ekki-ekkir   rv   )
rf   rg   randr   r   rN   r   rO   r   r   rw   s   &&  r   rx   -TestDifferentialEntropy.test_input_validation   s    IINN2JJqxxz"?]]:W55&&qr2 6 /]]:W55&&q= 65	 65 655s   %C,C"C	"C3	r   r   van esebrahimicorreaarray_api_strictzNeeds fancy indexing.r
   )marksc                P   VR 8X  d   RMRp\         P                  P                  V^ R7      pVP                  VP	                  4       4      pVP                  \        \         P                  P                  4       4      4      p\         P                  ! WAR7      p\        WeRR7       R# )r   '  i@B sizer   r   {Gzt?)rtolN)	r   r   rvsr   r   floatr   r   r   )r   r   r   nr   expectedrk   s   &&&    r   test_consistency(TestDifferentialEntropy.test_consistency   sv     x'EWjjnn!!n4jj&::eEJJ$6$6$89:((<E2r   distc                :   R ^2^repV P                   V,          V,          pVP                  V^ ,          4      VP                  V^,          4      rVP                  WE3^ R7      p
VP                  V
P                  4       4      p
VP                  \	        VP                  4       4      4      p\        P                  ! WVRR7      p\        VP                  VP                  W,
          ^,          4      4      VRR7       \        VP                  V^ R7      V	RR7       R# )	r   r   )r   r   rA   r   )atol)
correctiongMb`?Nre   )rmse_std_casesr   r   r   r   r   r   r   r   sqrtmeanstd)r   r   r   r   repsr   mr   rmse_expectedstd_expectedr   true_entropyrk   s   &&&&         r   test_rmse_std%TestDifferentialEntropy.test_rmse_std  s     B&&t,V4&(jj!&=rzz(ST+?V|hhTIAh6jj&zz%"78((06RA);a(? @A%E	3sq1<eLr   z	n, methodc                    \         P                  P                  V3^ R7      pVP                  VP	                  4       4      p\         P
                  ! V4      p\         P
                  ! WBR7      p\        WV4       R# )r   r   r   N)r   r   r   r   r   r   r   )r   r   r   r   r   res1res2s   &&&&   r   test_method_auto(TestDifferentialEntropy.test_method_auto#  sX     jjnn1$Qn7jj&))#.))#=#r   dtypeNc                   . ROp\        V\        V4      R4      p\        V\        V4      VP                  R4      P                  4      p\        P
                  ! VP                  WER7      VR7      p\        P
                  ! VP                  WAP                  R7      VR7      p\        WqP                  WR7      R,          4       R# )rd   Nr0   )r   r   )rd   rd   rc   r   r         r            	   ro   rq   rz   )getattrstrr   r   r   r   float64r   )	r   r   r   r   r2   dtype_in	dtype_outrk   r   s	   &&&&     r   test_dtypes_gh21192+TestDifferentialEntropy.test_dtypes_gh21192/  s     92s5z40BE
BJJrN,@,@A	((A)FvV((AZZ)HQWXZZZ=bABr   rz   )gMbX?灕Cl?)gA`"?g)\(?)gHzG?gy&1?)gMb?r   )gE?l?)gx?gOn?)gףp=
?g~jt?)gS?r   ))r   r   )rp   r   )i  r   )Nfloat32r   )r{   r|   r}   r~   __doc__r   r   r   r   r   rx   rN   markparametrizeparamskip_xp_backendsr   norm_rmse_std_casesexpon_rmse_std_casesr   r   r   r   r   r   r   r   r   s   @r   r   r   x   s    @"&(42

> [[X"#5*AC	
		( 	3	3 %n#^#^%~	 &~$n$n&	 /13N [[X"#5*AC	
		( 	 [[VdE]3M 4	M  [[[ + 
$
$ [[X"#5>UV	
 	(  [[W&BC	C D	Cr   r   )r)   rN   r   r   numpyrf   scipyr   scipy.statsr   r   scipy._lib._array_api_no_0dr   r   r	   r   r   r   r   rz   r   r   <module>r      s      *   #9 9 ;;// l3MNf& f& Of&R l3MNIC IC OICr   