+
    /i                     &   ^ RI t ^ RIt^ RIt^ RIHtHt ^ RIHtHt ^ RI	H
t
HtHtHtHtHtHtHt ^ RIHt ^ RIHtHt R tR tR	 t ! R
 R4      t ! R R4      t ! R R4      t ! R R4      t ! R R4      tR t ! R R4      t  ! R R4      t!R# )    N)raiseswarns)xp_assert_closexp_assert_equal)	argrelmax	argrelminpeak_prominencespeak_widths_unpack_condition_args
find_peaksfind_peaks_cwt_identify_ridge_lines)gaussian)_local_maxima_1dPeakPropertyWarningc                 0   \         P                  ! ^ V4      P                  \        4      p\         P                  ! V\        R7      p\        V4       F@  w  rVW0V,          ,
          V,          pV\         P                  ! V^,          ) 4      ,          pKB  	  V# )r   dtype)nparangeastypefloatzeros	enumerateexp)center_locssigmastotal_lengthxdataout_dataindsigmatmps   &&&     b/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/signal/tests/test_peak_finding.py_gen_gaussiansr%      sp    IIa&--e4ExxE2H'
3''50BFFS!V9%% ( O    c                     \        V 4      pW^,           ,          p\        P                  ! W1V,
          VR7      P                  \        4      p\        W@V4      pWT3# )   )num)lenr   linspacer   intr%   )r   r   	num_peaksdeltar   r    s   &&    r$   _gen_gaussians_evenr/      sM    FIM*E++eE%9yIPPQTUKk<@H  r&   c                H   R p\         P                  ! V4      p\         P                  ! V4      p\        P                  ! V^.\        R7      pWR&   V^ ,          V ^ ,          ,
          \        V4      ,
          pWr8  d   \        R4      hV\        V4      ,          ^,
          pV\        V4      ,          ^,
          p	\        ^V4       F  p
Wj^,
          ^3,          pWj^,
          ^ 3,          ^,           pW,          ^ 8X  d6   \        V4      ^ 8  d&   VRV
,          VP                  4       ,          ,          pW,          ^ 8X  d'   \        V4      ^ 8  d   WP                  4       ,          pV! W^ ,          4      pV! W^,          4      pW.WjR3&   K  	  VR,          VR,          .# )	a  
Generate coordinates for a ridge line.

Will be a series of coordinates, starting a start_loc (length 2).
The maximum distance between any adjacent columns will be
`max_distance`, the max distance between adjacent rows
will be `map_gap'.

`max_locs` should be the size of the intended matrix. The
ending coordinates are guaranteed to be less than `max_locs`,
although they may not approach `max_locs` at all.
c                 4    \        V ^ 4      p\        W!4      pV# r   )maxmin)r)   max_valouts   && r$   keep_bounds$_gen_ridge_line.<locals>.keep_bounds5   s    #qk#
r&   r   NNNz3Cannot generate ridge line according to constraints)r   r9   )r9   r   )r9   r(   )
copydeepcopyr   r   r,   sum
ValueErrorr*   rangepop)
start_locsmax_locslength	distancesgapsr7   locsr   dist_intgap_intr!   nextcolnextrows   &&&&&        r$   _gen_ridge_linerK   '   sX   
 ==Di(I88VQKs+DJA;A.T:LNOOI&*Hs4y 1$GQQwz"Qwz"Q&Nac)nq&8c	9==?22GMQSY]xxz!Gg{3g{3)!V   JT
##r&   c            	          a  ] tR t^Rt o R tR tR tR t]P                  P                  R]P                  ! . R
O4      ]P                  ! . RO4      ]P                  ! . RO4      .4      R 4       tR tRtV tR	# )TestLocalMaxima1dc                    \         P                  ! . \         P                  R7      p\        V4       F5  p\	        V\         P                  ! . 4      RR7       VP
                  f   K5  Q h	  R# )zTest with empty signal.r   Fcheck_dtypeN)r   arrayfloat64r   r   baseselfxrQ   s   &  r$   
test_emptyTestLocalMaxima1d.test_emptyT   sI    HHRrzz*%a(EE288B<UC::%%% )r&   c           	         \         P                  ! ^ ^d4      p\        V4       FC  p\        V\         P                  ! . \         P
                  R7      4       VP                  f   KC  Q h	  R# )zTest with linear signal.r   N)r   r+   r   r   rQ   intprS   rT   s   &  r$   test_linearTestLocalMaxima1d.test_linear[   sJ    KK3%a(EE288Bbgg#>?::%%% )r&   c                   \         P                  ! R^
^24      pVR;;,          ^,          uu&   \         P                  ! ^^2^\         P                  R7      p\	        V4       F   p\        W2RR7       VP                  f   K   Q h	  R# )zTest with simple signal.:   N   r   FrO   N)r   r+   r   rZ   r   r   rS   )rU   rV   expectedrQ   s   &   r$   test_simpleTestLocalMaxima1d.test_simpleb   sd    KKR$	$199QARWW5%a(E E?::%%%	 )r&   c                *   \         P                  ! . RO4      p\        V4      w  r#p\        V\         P                  ! . RO4      RR7       \        V\         P                  ! . RO4      RR7       \        V\         P                  ! . RO4      RR7       R# )z+Test if flat maxima are detected correctly.FrO   N)gr   r(   r   r^   r^   r   r_   r_   r_   gQ@   re   re   re   r`   rf   rf   rf   rf   r`   )r^   re            )r^   re            )r^      	         )r   rQ   r   r   )rU   rV   	midpoints
left_edgesright_edgess   &    r$   test_flat_maxima"TestLocalMaxima1d.test_flat_maximam   sf    HH / 0-=a-@*	{	288,=#>ER
BHH->$?USRXX.?%@eTr&   rV   c           	         \        V4       FC  p\        V\        P                  ! . \        P                  R7      4       VP
                  f   KC  Q h	  R# )z,Test if behavior on signal edges is correct.r   N)r   r   r   rQ   rZ   rS   rT   s   && r$   test_signal_edges#TestLocalMaxima1d.test_signal_edgesv   s<     &a(EE288Bbgg#>?::%%% )r&   c           	     h   \        \        RR7      ;_uu_ 4        \        \        P                  ! R
4      4       RRR4       \        \        RR7      ;_uu_ 4        \        \        P                  ! ^\
        R7      4       RRR4       \        \        RR7      ;_uu_ 4        \        RR.4       RRR4       \        \        R	R7      ;_uu_ 4        \        R4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     Le; i  + '       g   i     R# ; i)z,Test input validation and raised exceptions.zwrong number of dimensionsmatchNzexpected 'const float64_t'r   list      ?       @z'x' must not be None)r(   r(   )r   r>   r   r   onesr,   	TypeErrorrU   s   &r$   test_exceptions!TestLocalMaxima1d.test_exceptions   s    J&BCCRWWV_- DJ&BCCRWWQc23 DIV,,b"X& -I%;<<T" =< DCCC,,<<<s/    C'&C:"DD 'C7	:D
	D	 D1	 N)r}   r   r^   )      @r_   r   re   re   )      @rm   rm   r      r   r   )__name__
__module____qualname____firstlineno__rW   r[   rb   rt   pytestmarkparametrizer   rQ   rw   r   __static_attributes____classdictcell____classdict__s   @r$   rM   rM   R   st     &&	&U [[S

!"
'(# 
&
&	# 	#r&   rM   c                   D   a  ] tR t^t o R tR tR tR tR tR t	Rt
V tR# )	TestRidgeLinesc                    \         P                  ! ^^d.4      p\        V\         P                  ! ^^4      ^4      p\	        V4      ^ 8X  g   Q hR# )rp   Nr   r   r   fullr*   rU   	test_matrliness   &  r$   rW   TestRidgeLines.test_empty   s<    HHb#Y'	%iQC5zQr&   c                J   \         P                  ! ^^d.4      p^VR&   \        V\         P                  ! ^^4      ^4      p\	        V4      ^8X  g   Q h\         P                  ! ^^d.4      p^VR&   \        V\         P                  ! ^^4      ^4      p\	        V4      ^8X  g   Q hR# )rp   N)r   
   ):r   r^   Nr   r   r   s   &  r$   test_minimalTestRidgeLines.test_minimal   s    HHb#Y'		%%iQC5zQHHb#Y'		'%iQC5zQr&   c                   . ROp. ROp\         P                  ! ^^2.4      R,           p^p\        ^ ^.VP                  WAV4      p^W5^ ,          V^,          3&   \         P                  ! ^\        V4      4      p\        VV\        V4      ^,           4      p\        V4      ^8X  g   Q h\        V^ ,          V4       F  w  r\        WRR7       K  	  R# )r   g-q=FrO   Nr   r(   r^   rm   )r   r(   r^   r   r(   )
r   r   rK   shaper   r3   r   r*   zipr   )
rU   rD   rE   r   rC   linemax_distancesidentified_linesiline_line_s
   &         r$   test_single_passTestRidgeLines.test_single_pass   s     	HHb"X&.	2w	DQ&'	q'47"#C	N301>14TQ@ #$))) !1!!4d;MFFu= <r&   c                   . ROp. ROp\         P                  ! ^^2.4      p^p\        ^ ^.VP                  WAV4      p^W5^ ,          V^,          3&   ^p\         P                  ! ^V4      p\        VV\        V4      ^,           4      p\        V4      ^8X  g   Q hV F  p	\         P                  ! V	^,          4      p
\         P                  P                  \         P                  ! V
4      V4       \         P                  ! V	^ ,          4      p\         P                  P                  \         P                  ! V4      \        V4      R,           4       K  	  R# )r   皙?Nr   )r   r(   r^   re   )r   r   rK   r   r   r   r3   r*   difftestingassert_array_lessabs)rU   rD   rE   r   rC   r   max_distr   r   ilineadistsagapss   &           r$   test_single_bigdist"TestRidgeLines.test_single_bigdist   s    	HHb"X&	2w	DQ&'	q'47"#H-01>14TQ@ #$)))%EWWU1X&FJJ((BGGE!H%EJJ((D	CH &r&   c                   . ROp^p. ROp\         P                  ! ^^2.4      p^p\        ^ ^.VP                  WQV4      p^WF^ ,          V^,          3&   ^p\         P                  ! ^V4      p\        WHV4      p	\        V	4      ^8X  g   Q hV	 F  p
\         P                  ! V
^,          4      p\         P                  P                  \         P                  ! V4      V4       \         P                  ! V
^ ,          4      p\         P                  P                  \         P                  ! V4      \        V4      R,           4       K  	  R# )r   r   Nr   )r   re   r^   r(   r   r   rK   r   r   r   r*   r   r   r   r   r3   rU   rD   max_gaprE   r   rC   r   r   r   r   r   r   r   s   &            r$   test_single_biggap!TestRidgeLines.test_single_biggap   s     	HHb"X&	2w	DQ&'	q'47"#H-07S#$)))%EWWU1X&FJJ((BGGE!H%EJJ((D	CH &r&   c                   ^ .p^p^^.p\         P                  ! ^2^2.4      p^p\        ^ ^.VP                  WQV4      p^WF^ ,          V^,          3&   ^p\         P                  ! ^2V4      p\        WHV4      p	\        V	4      ^8X  g   Q hV	 F  p
\         P                  ! V
^,          4      p\         P                  P                  \         P                  ! V4      V4       \         P                  ! V
^ ,          4      p\         P                  P                  \         P                  ! V4      \        V4      R,           4       K  	  R# )r   r   Nr   r   s   &            r$   test_single_biggaps"TestRidgeLines.test_single_biggaps   s    C	1vHHb"X&	2w	DQ&'	q'47"#H-07S#$)))%EWWU1X&FJJ((BGGE!H%EJJ((D	CH &r&   r   N)r   r   r   r   rW   r   r   r   r   r   r   r   r   s   @r$   r   r      s,     
	>I,I*I Ir&   r   c                   8   a  ] tR t^t o R tR tR tR tRtV t	R# )
TestArgrelc                   \         P                  ! . \        R 7      p\         P                  ! ^4      p\	        V4      p\        \        V4      ^4       \        V^ ,          VRR7       \         P                  ! R4      p\	        V^ R7      w  rV\        WQRR7       \        WaRR7       \	        V^R7      w  rV\        WQRR7       \        WaRR7       R# )r   FrO   axisN)r_   rm   )r   rQ   r,   r   r   r   r*   )rU   empty_arrayz1iz2rowcols   &      r$   rW   TestArgrel.test_empty   s     hhr-XXa[bMA"!ku=XXfRa(e<e<Ra(e<e<r&   c                   \         P                  ! . RO. RO. RO. RO. R	O.4      p\        V^ R7      w  r#\         P                  ! V4      p\	        W$,          . R
ORR7       \	        W4,          . RORR7       \        V^R7      w  r#\         P                  ! V4      p\	        W$,          . RORR7       \	        W4,          . RORR7       \        V^ R7      w  r#\         P                  ! V4      p\	        W$,          . R
ORR7       \	        W4,          . R
ORR7       \        V^R7      w  r#\         P                  ! V4      p\	        W$,          . R
ORR7       \	        W4,          . R
ORR7       R# )r(   r   FrO   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_   )re   r   r(   )r   r_   re   )r_   r(   r^   )r   rQ   r   argsortr   r   )rU   rV   r   r   orders   &    r$   
test_basicTestArgrel.test_basic	  s   
 HHo%%%%	' ( QQ'

3
I5A
I5AQQ'

3
I5A
I5AQQ'

3
I5A
I5AQQ'

3
I5A
I5Ar&   c                    ^p. ROp\        VR4      w  r4W4,          R,          W4V,           &   W4,          R,          W4V,
          &   \        W1RR7      ^ ,          p\        V4      \        V4      8X  g   Q hWT8H  P                  4       '       g   Q hR# )r^     gwJ?clip)r   modeN)r}   r~         $@r   g      .@)r/   r   r*   all)rU   r   r   	test_dataact_locsrel_max_locss   &     r$   test_highorderTestArgrel.test_highorder(  s    ,1&#>	&/&9'&A	U"#&/&9'&A	U"# fEaH< CM111(--////r&   c                   . ROp\        V^d4      w  r#^p\        P                  ! ^ \        V4      4      V,
          p\        P                  ! W"V,          .4      p\        V^^R7      w  rx\        ^ VP                  ^ ,          4       FV  p	Wy8H  p
\        W,          4      \        V4      8X  g   Q hW8V
,          WI,          ,
          8H  P                  4       '       d   KV  Q h	  R# )r}   )r   r   N)r}   r~   r   )	r/   r   r   r*   vstackr   r?   r   r   )rU   r   r   r   
rot_factor	rot_rangetest_data_2rel_max_rowsrel_max_colsrwindss   &          r$   test_2d_gaussiansTestArgrel.test_2d_gaussians3  s    !1&#>	
IIaY0:=	iii,@ AB%.{!%L";,,Q/0B &D|)*c(m;;;d!3jm!CDIIKKKK	 1r&   r   N)
r   r   r   r   rW   r   r   r   r   r   r   s   @r$   r   r      s!     =0B>	0L Lr&   r   c                   J   a  ] tR tRt o R tR tR tR tR tR t	R t
R	tV tR
# )TestPeakProminencesiB  c                   \        . RO. 4      p\        V\        P                  \        P                  \        P                  .4       F+  w  r#VP
                  ^ 8X  g   Q hVP                  V8X  d   K+  Q h	  \        . . 4      p\        V\        P                  \        P                  \        P                  .4       F+  w  r#VP
                  ^ 8X  g   Q hVP                  V8X  d   K+  Q h	  R# z>
Test if an empty array is returned if no peaks are provided.
Nr   )r	   r   r   rR   rZ   sizer   )rU   r6   arrr   s   &   r$   rW   TestPeakProminences.test_emptyD  s     y"-cBJJ#ABJC88q= =99%%% C r2&cBJJ#ABJC88q= =99%%% Cr&   c                   \         P                  ! . RO4      p\         P                  ! . RO4      p\         P                  ! . RO4      p\         P                  ! . RO4      pW,          \         P                  ! W,          W,          .^ R7      ,
          p\        W4      p\	        V^ ,          VRR7       \	        V^,          VRR7       \	        V^,          VRR7       R# )	zr
Test if height of prominences is correctly calculated in signal with
rising baseline (peak widths are 1 sample).
r   FrO   N)r:   333333?r   r(   皙	@g?g
ףp=
@g @)r(   r^   re   r   )r   r   r   rm   )r_   r_   rm   rj   )r   rQ   r3   r	   r   )rU   rV   peakslbasesrbasespromsr6   s   &      r$   r   TestPeakProminences.test_basicR  s     HH;<&,','26619ai"8qAAq(A59AE:AE:r&   c                   . ROp. ROp\        W4      w  r4p\        V\        P                  ! . RO4      RR7       \        V. RORR7       \        V. RORR7       . R	Op\        P                  ! . RO4      p\        W4      w  r4p\        V\        P                  ! . R
O4      4       \        WB^,
          RR7       \        WR^,           RR7       R# )z
Test edge cases.
FrO   N)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   asarrayrQ   rU   rV   r   r   r   r   s   &     r$   test_edge_cases#TestPeakProminences.test_edge_casesc  s    
 " 0 :vrzz+6EJ	u=	u= "# 0 :vrzz+67	u=	u=r&   c                (   \         P                  ! . RO^4      p\         P                  ! . RO^4      p\        VR,          VR,          4      w  r4p\        V\         P                  ! . RO4      4       \        V. RORR7       \        V. R	ORR7       R# )
*
Test with non-C-contiguous input arrays.
:NNr^   FrO   N)irn   rn   r   r_   r(   )r(   r^   re   )g      "@rn   r^   )r   r   r_   )r_   r_   rm   )r   repeatr	   r   r   r   s   &     r$   test_non_contiguous'TestPeakProminences.test_non_contiguousw  si     II)1-		)Q' 03s Dvrzz+67	u=	u=r&   c                    . ROp^.p\        W4      p\        V. RO4       F  w  rEWE8X  d   K  Q h	  R FF  w  rg\        WV4      p\        VRV,
          ^ V,           ^V,
          .4       F  w  rEWE8X  d   K  Q h	  KH  	  R# )z?
Test if wlen actually shrinks the evaluation range correctly.
r   N)r   r(   r^   r_   r(   r   r:   )r   r   r   ))rg   r   )rj   r   )r   r   )rm   r(   )r   r(   r_   r^   )皙?r^   )r	   r   )rU   rV   peakr   promvalwlenr   s   &       r$   	test_wlenTestPeakProminences.test_wlen  s     #s )UK0ID;; 1 TGD$Qd3E aQA(>?	{"{ @ Tr&   c                
   \        \        RR7      ;_uu_ 4        \        . R
O.^^.4       RRR4       \        \        RR7      ;_uu_ 4        \        . R
O^^..4       RRR4       \        \        RR7      ;_uu_ 4        \        ^^ .4       RRR4       \        \        RR7      ;_uu_ 4        \        . ^ .4       RRR4       R F4  p\        \        RR7      ;_uu_ 4        \        . ROV.4       RRR4       K6  	  \        \        RR7      ;_uu_ 4        \        . R
ORR.4       RRR4       \        \        RR7      ;_uu_ 4        \        \        P
                  ! ^
4      ^^.^R	7       RRR4       R#   + '       g   i     ELV; i  + '       g   i     EL7; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EK  ; i  + '       g   i     L; i  + '       g   i     R# ; i)z1
Verify that exceptions and warnings are raised.
	1-D arrayrz   Nnot a valid indexcannot safely castr  ffffff@r  r  )r   r(   r(   r   )ir:   r_     r(   r   r^   )r   r>   r	   r   r   r   )rU   ps   & r$   r   #TestPeakProminences.test_exceptions  s\   
 Jk22l^aV4 3 Jk22\QF84 3 Jk22Q% 3 J&9::R!% ; %A
*=>> QC0 ?> %
 I%9::\C:6 ; Jf--RYYr]QF; .-- 322 322 322 ;:: ?>> ;: .--sS   E9F F!/F5#G	G
%G19F
	F	!F2	5G		GG.	1H	c                4   RpR F4  p\        \        VR7      ;_uu_ 4        \        . ROV.4       RRR4       K6  	  \        \        VR7      ;_uu_ 4        \        . RO^.^R7       RRR4       R#   + '       g   i     K~  ; i  + '       g   i     R# ; i).
Verify that appropriate warnings are raised.
z!some peaks have a prominence of 0rz   Nr  )r   r(   r^   r  r   r(   r(   r(   r   )r   r   r	   )rU   msgr  s   &  r$   test_warnings!TestPeakProminences.test_warnings  sq     2A*#66 QD1 76  &c22_qc: 32 766222s   A2B2BB	r   N)r   r   r   r   rW   r   r   r   r	  r   r  r   r   r   s   @r$   r   r   B  s-     &;">(	># <<	; 	;r&   r   c                      a  ] tR tRt o R t]P                  P                  R4      R 4       tR t	R t
R tR t]P                  P                  R4      R	 4       tR
tV tR# )TestPeakWidthsi  c                   \        . . 4      ^ ,          p\        V\        P                  4      '       g   Q hVP                  ^ 8X  g   Q h\        . RO. 4      ^ ,          p\        V\        P                  4      '       g   Q hVP                  ^ 8X  g   Q h\        . . 4      pV F8  p\        V\        P                  4      '       g   Q hVP                  ^ 8X  d   K8  Q h	  R# r   )r
   
isinstancer   ndarrayr   )rU   widthsr6   r   s   &   r$   rW   TestPeakWidths.test_empty  s     R$Q'&"**----{{aY+A.&"**----{{a"b!Cc2::....88q= = r&   #ignore:some peaks have a width of 0c           	        \         P                  ! . RO4      p^pR F  w  r4rV\        V^.V4      w  rxr\        V\         P                  ! V.4      4       \        V\         P                  ! ^W2,          ,
          .4      4       \        V	\         P                  ! V.4      4       \        V
\         P                  ! V.4      4       K  	  R# )zS
Test a simple use case with easy to verify results at different relative
heights.
N)r(   r   r(   r^   r(   r   r:   ))        r$  r   r   )g      ?r}         @      @)      ?r~   r~         @)      ?r         ?      @)r}   r(  r}   r   )r~   r   r}         @)r   r   r}   r,  )r   rQ   r
   r   r   )rU   rV   
prominence
rel_height
width_truelip_truerip_true
width_calcheightlip_calcrip_calcs   &          r$   r   TestPeakWidths.test_basic  s     HH+,
;
6JH 6AA3
6$2JJ

J<(@AFBJJJ4K0K/L$MNHbjj(&<=Hbjj(&<=;
r&   c           	         \         P                  ! . RO^4      p\         P                  ! ^.^4      p\        VR,          VR,          4      p\        V\         P                  ! R.^K.R.R..4      4       R# )r   :NNre   :NNr_   r)  r*  N)r   d   2   )r   r   r
   r   r   )rU   rV   r   results   &   r$   r   "TestPeakWidths.test_non_contiguous  sa     IIlA&		1#q!QsVU3Z0

TFRD4&3%#@A	
r&   c           
        \        \        RR7      ;_uu_ 4        \        \        P                  ! R4      \        P
                  ! ^4      4       RRR4       \        \        RR7      ;_uu_ 4        \        ^^ .4       RRR4       \        \        RR7      ;_uu_ 4        \        \        P                  ! ^
4      \        P
                  ! R\        P                  R7      4       RRR4       \        \        RR7      ;_uu_ 4        \        \        P                  ! ^
4      ^4       RRR4       \        \        RR7      ;_uu_ 4        \        \        P                  ! ^
4      ^^.4       RRR4       \        \        RR7      ;_uu_ 4        \        . ^^.4       RRR4       \        \        RR7      ;_uu_ 4        \        \        P                  ! ^
4      RR.4       RRR4       \        \        R	R7      ;_uu_ 4        \        . RO^^.RR
7       RRR4       \        \        RR7      ;_uu_ 4        \        . RO^.RR7       RRR4       R#   + '       g   i     EL	; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELn; i  + '       g   i     EL>; i  + '       g   i     EL"; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)z4
Verify that argument validation works as intended.
r  rz   Nr   r  r  r  r  r.  r.  Noneprominence_data)r_   re   r  )r   r(   r   r(   r   r:   )r(   r^   r(   )NNN)	r   r>   r
   r   r   r   r   rZ   r   r   s   &r$   r   TestPeakWidths.test_exceptions  s    Jk22("''!*5 3 Jk22A3 3 Jk22		"rwwvRWW'EF 3 Jk22		"q) 3 J&9::		"2w/ ; J&9::QF# ; I%9::		"Sz2 ; Jl33!QB? 4 IV,,	A38JK -,1 322 322 322 322 ;:: ;:: ;: 43 -,,sl   5I0I#AI7!J#JJ3;#K?K3K-I 	#I4	7J	J	J0	3K	K	K*	-K>	c                   Rp\        \        VR7      ;_uu_ 4        \        . RO^.^ R7       RRR4       \        \        VR7      ;_uu_ 4        \        . RO^.\        P                  ! R.\        P
                  4      \        P                  ! ^.\        P                  4      \        P                  ! ^.\        P                  4      3R7       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)	r  zsome peaks have a width of 0rz   r=  Nr$  r?  r   r(   r   r  )r   r   r
   r   rQ   rR   rZ   )rU   r  s   & r$   r  TestPeakWidths.test_warnings  s     -&c22	A315 3 &c22!!#2$

!;!#1#rww!7!#1#rww!7!9 32 32 322s   CBC-C*	-C>	c           	        . ROp^.p\        . RO4       F  w  pw  rEp\        P                  ! V\        P                  R7      \        P                  ! V\        P                  R7      \        P                  ! V\        P                  R7      3pV^8  d   RpMRp\        \        VR7      ;_uu_ 4        \        WVR7       RRR4       K  	  R#   + '       g   i     K  ; i)	z4Test with mismatching peak and / or prominence data.r   z#prominence data is invalid for peakz4arrays in `prominence_data` must have the same shaperz   r?  NrC  ))r}   )r:   r^   )rF  r2   )r_   )rF  rG  r2   )r}   r}   r   r   r^   r^   )rH  r2   rG  )rF  rI  rG  )rF  r2   rJ  )r   r   rQ   rR   rZ   r   r>   r
   )	rU   rV   r  r   prominences
left_basesright_basesr@  r{   s	   &        r$    test_mismatching_prominence_data/TestPeakWidths.test_mismatching_prominence_data!  s    s9B D
 :5A5  "xx2::F!xx
"''B!xx277CEO 1u=N
%00A_E 10%:$ 100s   4CC!c                z    . ROp\        \        V^.^ R7      . RO4       \        \        V^.RR7      . RO4       R# )z3Test if x == eval_height counts as an intersection.)r   r.  N)r   r(   r^   r(   r_   r_   r_   r(   r^   r(   r   ))r$  r   r   rR  gUUUUUU?))r(  rF  rQ  )g      @)r   r
   )rU   rV   s   & r$   test_intersection_rules&TestPeakWidths.test_intersection_rules:  s;     .AaSQ?4	6 	AaSSA4	6r&   r   N)r   r   r   r   rW   r   r   filterwarningsr   r   r   r  rN  rS  r   r   r   s   @r$   r  r    sk     ! [[ EF> G>.	
L@"F2 [[ EF	6 G	6r&   r  c                    \         P                  ! ^
4      p T pV^
,           pVR,          pR\        RW4      8X  g   Q hR\        ^W4      8X  g   Q hR\        RW4      8X  g   Q hR\        RW4      8X  g   Q hR	\        R	W4      8X  g   Q h\        W3W4      w  rE\        WAV,          4       \        WRV,          4       \	        \
        RR7      ;_uu_ 4        \        V\         P                  ! ^4      V4       RRR4       \	        \
        RR7      ;_uu_ 4        \        RV3\         P                  ! ^4      V4       RRR4       R#   + '       g   i     LW; i  + '       g   i     R# ; i)
zO
Verify parsing of condition arguments for `scipy.signal.find_peaks` function.
r(   Nr^   Nzarray size of lowerrz   zarray size of upperNN)r(   NNr^   )r   r+  )r   r   r   r   r   r>   )rV   	amin_true	amax_truer   	amin_calc	amax_calcs         r$   test_unpack_condition_argsr^  G  s1    			"AIBIdOE 1,IIII.q!;;;;.y!CCCC.y!CCCC.y!CCCC 292H!SII/0I/0 

"7	8	8y"))B-? 
9	
"7	8	8i0"))B-G 
9	8 
9	8	8	8	8s   "E$EE	E+	c                      a  ] tR tRt o 0 RmtR tR tR tR tR t	R t
R tR	 tR
 t]P                  P!                  RR4      R 4       t]P                  P%                  R/ RR/RR/RR/.4      R 4       tRtV tR# )TestFindPeaksic  c                    Rp\        \        P                  ! ^
4      WWR7      w  r#VP                  ^ 8X  g   Q hV P                   F  pW4,          P                  ^ 8X  d   K  Q h	  R# )z0
Test behavior for signal without local maxima.
Nr3  	thresholdr-  widthrX  )r   r   r   r   property_keys)rU   open_intervalr   propskeys   &    r$   test_constantTestFindPeaks.test_constantj  s\     %!"''"+)6-:Q zzQ%%C:??a''' &r&   c                   \         P                  ! . R
O4      p\         P                  ! VP                  ^,          ^,           4      pWR&   \         P                  ! VP                  \
        R7      pVR,          VR&   \         P                  ! W#4      p\        VRR7      w  rE\        V. RORR7       \        VR,          VRR7       \        VR,          WA^,
          ^,          ,
          RR7       \        VR	,          WA^,          ,           RR7       \        \        V^R7      ^ ,          . RORR7       \        \        VRR7      ^ ,          . RORR7       \        \        VRR7      ^ ,          ^^!.RR7       R# )z(
Test plateau size condition for peaks.
rW  r   N)plateau_sizeFrO   plateau_sizesrr   rs   )r(   r^   r_   re   rg   rp   o   rX  )r(   r_   rj   rk   ri   !   r8  )rk   ri   ro  r8  )Nr&  )r(   r_   rj   )rm   r9  )	r   rQ   r   r   r   r,   r   r   r   )rU   rm  rV   repeatsr   rg  s   &     r$   test_plateau_sizeTestFindPeaks.test_plateau_sizev  s*   
 !9:HH]''!+a/0$''!&&,$IIa! "!,?9uMo.5Ql+Ua6GA5M-M$)	+m,eq6H.H$)	+ 	
115a8:K$)	+
1;?BI$)	+
17;A>R$)	+r&   c                   Rp\        VRR7      w  r#\        V\        P                  ! . R	O4      RR7       \        VR,          \        P                  ! . R
O4      RR7       \        \        VRR7      ^ ,          \        P                  ! ^^.4      RR7       \        \        VRR7      ^ ,          \        P                  ! ^^.4      RR7       \        \        VRR7      ^ ,          \        P                  ! ^.4      RR7       R# )z"
Test height condition for peaks.
N)r3  FrO   peak_heightsr'  )r$  UUUUUU?r$  r%  r   r(  r   rX  r   )ru  r%  r(  )Nr_   )r^   r_   )r   r   r   rQ   rU   rV   r   rg  s   &   r$   test_height_condition#TestFindPeaks.test_height_condition  s     )!!L9rxx	2Fn-rxx/G$)	+
1S1!4bhh1v6F$)	+
1Y7:BHHaV<L$)	+
1V4Q71#$)	+r&   c                <   Rp\        VRR7      w  r#\        V\        P                  ! ^^.4      RR7       \        VR,          \        P                  ! RR.4      4       \        VR,          \        P                  ! R	R
.4      4       \        \        V^R7      ^ ,          \        P                  ! ^.4      RR7       \        \        VRR7      ^ ,          \        P                  ! . \        R7      RR7       \        \        VRR7      ^ ,          \        P                  ! ^^.4      RR7       \        \        VRR7      ^ ,          \        P                  ! ^.4      RR7       \        \        VRR7      ^ ,          \        P                  ! . \        R7      RR7       R# )z%
Test threshold condition for peaks.
N)rc  FrO   left_thresholdsr~   r   right_thresholdsr}   r   r&  r   )r   r^   r(   re   r:   rX  )Nrm   )Nre   )r^   re   )r   r   r   rQ   r,   rv  s   &   r$   test_threshold_condition&TestFindPeaks.test_threshold_condition  s(    !!|<rxxA/UC/0"((C:2FG01288S#J3GH
1215rxx}$)	+
14Q7"C9P$)	+
1	:1=rxxA?O$)	+
1	:1=rxx}$)	+
17:BHHRs<S$)	+r&   c                p   \         P                  ! ^^^4      p\         P                  ! ^4      pW!;;,          \         P                  ! ^^VP                  4      ,          uu&   \        \        V^R7      ^ ,          VRR7       \        VRR7      ^ ,          p\         P                  ! W1RR7      P                  ^ 8X  g   Q h\         P                  ! V4      p\        V^\         P                  ! V4      ,          4       . ROp\        V^
R7      ^ ,          pVP                  ^8X  d   V^ ,          ^8X  g   Q hR# )	z$
Test distance condition for peaks.
distanceFrO   g9m4 @T)assume_uniqueN)r(   r:   r   )
r   r   r   r+   r   r   r   	setdiff1dr   	ones_like)rU   	peaks_allrV   peaks_subsetdfss   &    r$   test_distance_condition%TestFindPeaks.test_distance_condition  s    
 IIaQ'	HHRL	Aq)..99 	
1q1!4iUS "!f5a8||L4HMMQRRRR ggl#Qr||C001 !!b1!4  A%,q/Q*>>>*>r&   c                   \         P                  ! ^ ^
^d4      p\         P                  ! ^^c^4      p\         P                  ! ^^
VP                  4      pW;;,          V,          uu&   W,          W^,           ,          ,
          pRp\         P                  ! V^ ,          V8*  WE^,          8*  ,          4      p\        WR7      w  rx\        WrV,          RR7       \        VR,          WF,          RR7       \        VR,          \         P                  ! VR,          4      4       \        VR,          W&,          ^,           RR7       R# )	z&
Test prominence condition for peaks.
)r-  FrO   rK  rL  rM  N)r_   rn   )r   r+   r   r   nonzeror   r   
zeros_like)	rU   rV   
peaks_trueoffsetrK  intervalkeep
peaks_calc
propertiess	   &        r$   test_prominence_condition'TestFindPeaks.test_prominence_condition  s     KK2s#YYq"a(
QJOO4	maQ&77zza[K'KA;,FGI ",A!C

t$4%H
=1;3DRWX
<0j&>?	A
=1:3Ca3G$)	+r&   c                
   \         P                  ! . RO4      p\        VRRR7      w  r#VP                  ^8X  g   Q h\	        V^\         P
                  ! V4      ,          4       \        VR,          \         P                  ! R.4      4       \        VR,          \         P                  ! R.4      4       \        VR,          \         P                  ! R	.4      4       \        VR
,          \         P                  ! R.4      4       R# )z!
Test width condition for peaks.
Nr)  )rd  r.  r   g?width_heightsr}   left_ipsg@	right_ipsg      @)	r(   r   r(   r^   r(   r   r:   re   r   rY  )r   rQ   r   r   r   r  r   r   rv  s   &   r$   test_width_condition"TestFindPeaks.test_width_condition  s     HH12!!9FzzQqe!445hTF);<o.

B40@Aj)2::se+<=k*BJJv,>?r&   c                    Rp. ROp\        VWWR7      w  r4\        V4      \        V P                  4      8X  g   Q hV P                   F&  pVP                  WE,          P                  8X  d   K&  Q h	  R# )z
Test returned properties.
Nrb  rX  )
r   r(   r   r^   r*  r   r_   r   rm   rn   )r   r*   re  r   )rU   rf  rV   r   rg  rh  s   &     r$   test_propertiesTestFindPeaks.test_properties  sj     %,!!)6-:Q 5zS!3!34444%%C::000 &r&   c                   \        \        RR7      ;_uu_ 4        \        \        P                  ! ^4      4       RRR4       \        \        RR7      ;_uu_ 4        \        \        P
                  ! R4      4       RRR4       \        \        RR7      ;_uu_ 4        \        \        P                  ! ^
4      RR7       RRR4       R#   + '       g   i     L; i  + '       g   i     Lh; i  + '       g   i     R# ; i)z%
Test exceptions raised by function.
r  rz   Nr  r  rJ  r:   )r   r>   r   r   rQ   r   r   r   s   &r$   test_raisesTestFindPeaks.test_raises   s     Jk22rxx{# 3Jk22rwwv' 3Jj11ryy}r2 21	 3222111s#    C C"C.C	C+	.C?	z(ignore:some peaks have a prominence of 0r"  c                   \        . ROR	R	^R7      w  r\        V^\        P                  ! V4      ,          4       \        VR,          \        P                  ! VR,          4      4       \        VR,          \        P                  ! VR,          4      4       \        VR,          \        P                  ! VR,          4      4       R
 F  p\        W#,          VRR7       K  	  R# )z
Test behavior of prominence and width calculation if the given window
length is smaller than a peak's plateau size.

Regression test for gh-9110.
N)r-  rd  r  rK  r   r  FrO   r  rX  )rL  rM  r  r  )r   r   r   r  r  )rU   r   rg  rh  s   &   r$   test_wlen_smaller_plateau'TestFindPeaks.test_wlen_smaller_plateau  s     "/l(41>q2<<#667m,bmmE-<P.QRhuX)GHo.U?=S0TUICEJ5A Jr&   kwargsr  r   r-  Nrd  c                    \         P                  ! ^ ^
^4      pVP                  4       pRVP                  n        \        V4      w  rE\        V3/ VB w  re\        WF4       R# )z$
Test readonly arrays are accepted.
FN)r   r+   r;   flags	writeabler   r   )rU   r  rV   
x_readonlyr   _peaks_readonlys   &&     r$   test_readonly_array!TestFindPeaks.test_readonly_array  sT     KK2r"VVX
%*
"a=&z<V<.r&   r   >
   r   r  r  rL  rK  rM  rt  r  rz  r{  rX  rY  )r   r   r   r   re  ri  rq  rw  r|  r  r  r  r  r  r   r   rU  r  r   r  r   r   r   s   @r$   r`  r`  c  s     ?M
(+:+ +(?4+*@1	3 [[ J EGBGB  [[X
	S	|$	)	( //r&   r`  c                   D   a  ] tR tRt o R tR tR tR tR tR t	Rt
V tR	# )
TestFindPeaksCwti2  c                    . ROpRp\        W4      w  r4\        P                  ! R\        V4      4      p\	        W5^^ RR7      p\        WdRRR7       R# )	zH
Generate a series of gaussians and attempt to find the peak locations.
r   r   N)
gap_threshmin_snr
min_lengthFz4Found maximum locations did not equal those expected)rP   err_msgr   r   r   g      4@r   g      I@)r/   r   r   r3   r   r   )rU   r   
num_pointsr   r   r   
found_locss   &      r$   test_find_peaks_exact&TestFindPeaksCwt.test_find_peaks_exact4  sR     4
1&E	3F,#I!Q48:

$) V	
r&   c                <   . ROpRp\        W4      w  r4\        P                  ! R\        V4      4      pRp\        P                  P                  R4      pW7P	                  V4      R,
          ^V,          ,          ,          p\        W5^^V^,          R7      pRp	\        V4      \        V4      8X  g   Q V	4       h\        P                  ! W,
          4      p
\        P                  ! V4      ^,          p\        P                  P                  WRR	V 2,           4       R
# )zb
Verify that peak locations are (approximately) found
for a series of gaussians with added noise.
r   r   gQ?or'  )r  r  r  z-Different number of peaks found than expectedzMaximum location differedzby more than Nr  )r/   r   r   r3   randomdefault_rngr   r*   r   rQ   r   r   )rU   r   r  r   r   r   	noise_amprngr  r  diffs	max_diffss   &           r$   test_find_peaks_withnoise*TestFindPeaksCwt.test_find_peaks_withnoiseC  s    
 4
1&E	3F,	ii##H-jj,s2Qy[AA	#I"45y1}N
 A:#h-/88/z,-HHV$q(	


$$U7R'4YK%@8A 	Br&   c                   Rp^dp\         P                  P                  R4      pVP                  V4      R,
          ^V,          ,          p\         P                  ! ^
^24      p\        WE^^R7      p\        V4      ^ 8X  g   Q hR# )z9
Verify that no peak is found in
data that's just noise.
r}   iW
r'  )r  
noise_percN)r   r  RandomStaterandr   r   r*   )rU   r  r  r  r   r   r  s   &      r$   test_find_peaks_nopeak'TestFindPeaksCwt.test_find_peaks_nopeakY  sn    
 	
ii##I.XXj)C/!I+>	2r"#IqRP
:!###r&   c                    \        ^^4      p\        P                  ! . RO4      p\        W\         R7      p\	        V\        P
                  ! ^d.4      RR7       R# )   )waveletFrO   N)r(   r^   r_   re   )r   r   rQ   r   r   r   )rU   rV   r   as   &   r$   )test_find_peaks_with_non_default_wavelets:TestFindPeaksCwt.test_find_peaks_with_non_default_waveletsf  s?    S!,'1h72::se,%@r&   c           	     d   RR.pRp\        W4      w  r4\        P                  ! R\        V4      R4      pRp\        P                  P                  R4      pW7P                  V4      R,
          ^V,          ,          ,          pVR;;,          ^,          uu&   \        W5^^R	R	R
7      p\        P                  ! \        4      ;_uu_ 4        VP                  VP                  8X  g   Q h R	R	R	4       \        W5^^R	^R
7      pVP                  VP                  8X  g   Q hR	#   + '       g   i     L?; i)zY
Verify that window_size is passed correctly to private function and
affects the result.
r~   r  r   g?皙?r  r'  :   i@  NN)r  r  r  window_size)r/   r   r   r3   r  r  r  r   r   r   AssertionErrorr   )	rU   r   r  r   r   r   r  r  r  s	   &        r$   test_find_peaks_window_size,TestFindPeaksCwt.test_find_peaks_window_sizem  s    
 s
1&E	3FS1	ii##H-hhz*S01Y;??	 	'a#I!Q/3G
]]>**??hmm333 + $I!Q/3E
(--/// +*s   	DD/	c                    \         P                  ! ^ \         P                  R4      p\         P                  ! V4      p^p\	        W#4      p\         P
                  P                  V^ 4       R# )zE
Verify that the `width` argument
in `find_peaks_cwt` can be a float
r  N)r   r   pisinr   r   assert_equal)rU   xsr   r   r  s   &    r$   test_find_peaks_with_one_width/TestFindPeaksCwt.test_find_peaks_with_one_width  sJ    
 YYq"%%&FF2J	#I6




B/r&   r   N)r   r   r   r   r  r  r  r  r  r  r   r   r   s   @r$   r  r  2  s*     
B,$A04
0 
0r&   r  )"r;   numpyr   r   r   r   scipy._lib._array_apir   r   scipy.signal._peak_findingr   r   r	   r
   r   r   r   r   scipy.signal.windowsr    scipy.signal._peak_finding_utilsr   r   r%   r/   rK   rM   r   r   r   r  r^  r`  r  r   r&   r$   <module>r     s         B	 	 	 * R!($V8# 8#v_I _IDPL PLfw; w;tH6 H6VH8L/ L/^_0 _0r&   