
    Џkh4                         d dl Zd dlmZ d dlmZmZmZ d dl	m
c mZ d ZddZd Zd Zd Z G d	 d
      Z G d d      Z G d d      Z G d d      Z G d d      Z G d d      Zy)    N)raises)assert_almost_equalxp_assert_equalxp_assert_closec                 "    |||z
  | z  |z  z   }|S N tf0f1t1fs        ]/var/www/teggl/fontify/venv/lib/python3.12/site-packages/scipy/signal/tests/test_waveforms.pychirp_linearr      s    
b2g]RAH    c                 d    |r|||z
  | dz  z  |dz  z  z   }|S |||z
  || z
  dz  z  |dz  z  z
  }|S )N   r	   )r   r   r   r   vertex_zeror   s         r   chirp_quadraticr      sW    "r'QT!BE)) H "r'b1fq[(2q500Hr   c                 "    |||z  | |z  z  z  }|S r   r	   r
   s        r   chirp_geometricr      s    
beqt_AHr   c                 4    ||z  |z  ||z
  | z  ||z  z   z  }|S r   r	   r
   s        r   chirp_hyperbolicr      s*    
2bR"WaK"R%'(AHr   c                     | d   | d   z
  }t        j                  |      dt         j                  z  z  |z  }d| dd | dd z   z  }||fS )zR
    Compute theta'(t)/(2*pi), where theta'(t) is the derivative of theta(t).
       r   r         ?N)npdiffpi)r   thetadtr   tfs        r   compute_frequencyr%   $   sW     
1!B
"%% 2%A	aeafn	Bq5Lr   c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)	TestChirpc                 P    t        j                  ddddd      }t        |d       y )Nr         ?       @linearr   r   r   r   method	waveformschirpr   selfws     r   test_linear_at_zerozTestChirp.test_linear_at_zero2   s"    OOaCCCIAs#r   c                    d}d}d}d}t        j                  d|d      }t        j                  |||||      }t	        ||      \  }}t        j
                  t        j                  |t        ||||      z
              }	|	dk  sJ y )Nr+   r)   r*   r   d   ư>r   linspacer/   _chirp_phaser%   maxabsr   
r2   r-   r   r   r   r   phaser$   r   abserrs
             r   test_linear_freq_01zTestChirp.test_linear_freq_016   s    KK2s#&&q"b"f=!!U+Aq<BB#??@A}}r   c                    d}d}d}d}t        j                  d|d      }t        j                  |||||      }t	        ||      \  }}t        j
                  t        j                  |t        ||||      z
              }	|	dk  sJ y )Nr+         i@      Y@      $@r   r6   r7   r8   r=   s
             r   test_linear_freq_02zTestChirp.test_linear_freq_02A   s    KK2s#&&q"b"f=!!U+Aq<BB#??@A}}r   c                 @   d}d}d}d}t        j                  d|d      }t        j                  |||||d      }t        j                  |||||d      }t        j                  |      }t        j                  |      }	|t        j
                  |	      z
  }
|
d	k  sJ y )
Nr+   r)   r*   r   r6   F)complexTr7   )r   r9   r/   r0   varreal)r2   r-   r   r   r   r   w_real	w_complexw_pwr_rw_pwr_cerrs              r   test_linear_complex_powerz#TestChirp.test_linear_complex_powerL   s    KK2s#BBFOOAr2r64H	&&.&&# ((Tzzr   c                 R    t        j                  dddddd      }t        |d       y )Nr         $r)   r+   Tr   r   r   r   r-   rG         ?        r/   r0   r   r1   s     r   test_linear_complex_at_zeroz%TestChirp.test_linear_complex_at_zero]   s'    OOaEcc($(*8$r   c                 P    t        j                  ddddd      }t        |d       y )Nr   r)   r*   	quadraticr,   r.   r1   s     r   test_quadratic_at_zeroz TestChirp.test_quadratic_at_zerob   s"    OOaCCCLAs#r   c                 R    t        j                  dddddd      }t        |d       y )Nr   r)   r*   rW   F)r   r   r   r   r-   r   r.   r1   s     r   test_quadratic_at_zero2z!TestChirp.test_quadratic_at_zero2f   s'    OOaCCC(-/As#r   c                 R    t        j                  dddddd      }t        |d       y )	Nr         r*   r)   rW   TrR   rS   rT   r1   s     r   test_quadratic_complex_at_zeroz(TestChirp.test_quadratic_complex_at_zerok   s'    OOaDSS$(*6"r   c                    d}d}d}d}t        j                  d|d      }t        j                  |||||      }t	        ||      \  }}t        j
                  t        j                  |t        ||||      z
              }	|	dk  sJ y )NrW   r)   r*   r     r7   r   r9   r/   r:   r%   r;   r<   r   r=   s
             r   test_quadratic_freq_01z TestChirp.test_quadratic_freq_01p   s    KK2t$&&q"b"f=!!U+Aq?2r2r#BBCD}}r   c                    d}d}d}d}t        j                  d|d      }t        j                  |||||      }t	        ||      \  }}t        j
                  t        j                  |t        ||||      z
              }	|	dk  sJ y )NrW         4@rD   r   r_   r7   r`   r=   s
             r   test_quadratic_freq_02z TestChirp.test_quadratic_freq_02{   s    KK2t$&&q"b"f=!!U+Aq?2r2r#BBCD}}r   c                 P    t        j                  ddddd      }t        |d       y )Nr   r)   r*   logarithmicr,   r.   r1   s     r   test_logarithmic_at_zeroz"TestChirp.test_logarithmic_at_zero   s"    OOaCCCNAs#r   c                    d}d}d}d}t        j                  d|d      }t        j                  |||||      }t	        ||      \  }}t        j
                  t        j                  |t        ||||      z
              }	|	dk  sJ y )Nrf   r)   r*   r   '  r7   r   r9   r/   r:   r%   r;   r<   r   r=   s
             r   test_logarithmic_freq_01z"TestChirp.test_logarithmic_freq_01   s    KK2u%&&q"b"f=!!U+Aq?2r2r#BBCD}}r   c                    d}d}d}d}t        j                  d|d      }t        j                  |||||      }t	        ||      \  }}t        j
                  t        j                  |t        ||||      z
              }	|	dk  sJ y )Nrf   rB   rC   rD   r   ri   r7   rj   r=   s
             r   test_logarithmic_freq_02z"TestChirp.test_logarithmic_freq_02       KK2u%&&q"b"f=!!U+Aq?2r2r#BBCD}}r   c                    d}d}d}d}t        j                  d|d      }t        j                  |||||      }t	        ||      \  }}t        j
                  t        j                  |t        ||||      z
              }	|	dk  sJ y )Nrf   rC   rD   r   ri   r7   rj   r=   s
             r   test_logarithmic_freq_03z"TestChirp.test_logarithmic_freq_03   rn   r   c                 P    t        j                  ddddd      }t        |d       y )Nr   rD   r)   
hyperbolicr,   r.   r1   s     r   test_hyperbolic_at_zeroz!TestChirp.test_hyperbolic_at_zero   s"    OOaDSSNAs#r   c                     d}d}t        j                  d|d      }ddgddgddgddgg}|D ]I  \  }}t        j                  |||||      }t	        ||      \  }}	t        ||||      }
t        |	|
d	       K y )
Nrr   r)   r   ri   rD   rQ   r\   gHz>)atol)r   r9   r/   r:   r%   r   r   )r2   r-   r   r   casesr   r   r>   r$   r   expecteds              r   test_hyperbolic_freq_01z!TestChirp.test_hyperbolic_freq_01   s    KK2u%t   	4FB**1b"b&AE%a/EB'BB7HAxd3		4r   c           	          d}d}t        j                  d|d      }t        t        t        j
                  |d|d|       t        t        t        j
                  |d|d|       y )Nrr   r)   r      r   r   r9   assert_raises
ValueErrorr/   r0   )r2   r-   r   r   s       r   test_hyperbolic_zero_freqz#TestChirp.test_hyperbolic_zero_freq   sN    KK2q!j)//1aQGj)//1aQGr   c           	          d}d}d}d}t        j                  d|d      }t        t        t        j
                  |||||       y )NfoorD   rc   r)   r   
   r{   )r2   r-   r   r   r   r   s         r   test_unknown_methodzTestChirp.test_unknown_method   s@    KK2r"j)//1b"b&Ir   c                     d}d}t        j                  ddd      }d}t        j                  ||||      }d}t        j                  ||||      }d}t	        |||	       y )
NrD   rc   r   r            @   z'Integer input 't1=3' gives wrong resulterr_msgr   r9   r/   r0   r   )r2   r   r   r   r   float_result
int_resultr   s           r   test_integer_t1zTestChirp.test_integer_t1   sa    KKAr" q"b"5__QB3
;
L'Br   c                     d}d}t        j                  ddd      }d}t        j                  ||||      }d}t        j                  ||||      }d}t	        |||	       y )
Nrc   r   r   r   r   rD   r   z(Integer input 'f0=10' gives wrong resultr   r   )r2   r   r   r   r   r   r   r   s           r   test_integer_f0zTestChirp.test_integer_f0   a    KKAr" q"b"5__QB3
<
L'Br   c                     d}d}t        j                  ddd      }d}t        j                  ||||      }d}t        j                  ||||      }d}t	        |||	       y )
NrD   r   r   r   r   rc      z(Integer input 'f1=20' gives wrong resultr   r   )r2   r   r   r   r   r   r   r   s           r   test_integer_f1zTestChirp.test_integer_f1   r   r   c                     d}d}d}t        j                  ddd      }t        j                  |t	        |      t	        |      t	        |            }t        j                  ||||      }d}t        |||       y )	Nr   r   r   r   r   r   z5Integer input 'f0=10, t1=3, f1=20' gives wrong resultr   )r   r9   r/   r0   floatr   )r2   r   r   r   r   r   r   r   s           r   test_integer_allzTestChirp.test_integer_all   sh    KKAr" q%)U2Yb	J__QB3
I
L'Br   N)__name__
__module____qualname__r4   r@   rE   rO   rU   rX   rZ   r]   ra   rd   rg   rk   rm   rp   rs   rx   r~   r   r   r   r   r   r	   r   r   r'   r'   0   sv    $		"%
$$
#
		$			$4HJ	C	C	CCr   r'   c                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	TestSweepPolyc                    t        j                  g d      }t        j                  ddd      }t        j                  ||      }t        ||      \  }} ||      }t        j                  t        j                  ||z
              }|dk  sJ y )N)r)           r)   r   r   ri   r7   r   poly1dr9   r/   _sweep_poly_phaser%   r;   r<   r2   pr   r>   r$   r   rw   r?   s           r   test_sweep_poly_quad1z#TestSweepPoly.test_sweep_poly_quad1   st    IIo&KK3&++Aq1!!U+AR5q8|,-}}r   c                    t        j                  d      }t        j                  ddd      }t        j                  ||      }t        ||      \  }} ||      }t        j                  t        j                  ||z
              }|dk  sJ y )Nr*   r   r   ri   r7   r   r   s           r   test_sweep_poly_constz#TestSweepPoly.test_sweep_poly_const  ss    IIcNKK3&++Aq1!!U+AR5q8|,-}}r   c                    t        j                  ddg      }t        j                  ddd      }t        j                  ||      }t        ||      \  }} ||      }t        j                  t        j                  ||z
              }|dk  sJ y )Nr\   rD   r   r   ri   r7   r   r   s           r   test_sweep_poly_linearz$TestSweepPoly.test_sweep_poly_linear  sx    IItTl#KK3&++Aq1!!U+AR5q8|,-}}r   c                    t        j                  g d      }t        j                  ddd      }t        j                  ||      }t        ||      \  }} ||      }t        j                  t        j                  ||z
              }|dk  sJ y )N)r)   r          r   r   ri   r7   r   r   s           r   test_sweep_poly_quad2z#TestSweepPoly.test_sweep_poly_quad2  su    II&'KK3&++Aq1!!U+AR5q8|,-}}r   c                    t        j                  g d      }t        j                  ddd      }t        j                  ||      }t        ||      \  }} ||      }t        j                  t        j                  ||z
              }|dk  sJ y )Nr*   r)   r   r   r   r*   ri   r7   r   r   s           r   test_sweep_poly_cubicz#TestSweepPoly.test_sweep_poly_cubic   su    II+,KK3&++Aq1!!U+AR5q8|,-}}r   c                 D   t        j                  g d      }t        j                  ddd      }t        j                  ||      }t        ||      \  }} t        j                  |      |      }t        j                  t        j                  ||z
              }|dk  sJ y)z1Use an array of coefficients instead of a poly1d.r   r   r*   ri   r7   N)	r   arrayr9   r/   r   r%   r   r;   r<   r   s           r   test_sweep_poly_cubic2z$TestSweepPoly.test_sweep_poly_cubic2)  s    HH*+KK3&++Aq1!!U+A299Q<#q8|,-}}r   c                    g d}t        j                  ddd      }t        j                  ||      }t	        ||      \  }} t        j
                  |      |      }t        j                  t        j                  ||z
              }|dk  sJ y)z/Use a list of coefficients instead of a poly1d.r   r   r*   ri   r7   N)r   r9   r/   r   r%   r   r;   r<   r   s           r   test_sweep_poly_cubic3z$TestSweepPoly.test_sweep_poly_cubic33  sv    !KK3&++Aq1!!U+A299Q<#q8|,-}}r   N)
r   r   r   r   r   r   r   r   r   r   r	   r   r   r   r      s%    r   r   c                   $    e Zd Zd Zd Zd Zd Zy)TestGaussPulsec                     t        j                  dd      }t        j                  dd      }d}t        |||       y )Ncutoffg     @@)fci  z*Integer input 'fc=1000' gives wrong resultr   r/   
gausspulser   r2   r   r   r   s       r   test_integer_fczTestGaussPulse.test_integer_fc@  s7     ++H@))(t<
>
L'Br   c                     t        j                  dd      }t        j                  dd      }d}t        |||       y )Nr   r)   )bwr   z'Integer input 'bw=1' gives wrong resultr   r   r   s       r   test_integer_bwzTestGaussPulse.test_integer_bwF  s7     ++H=))(q9
;
L'Br   c                     t        j                  dd      }t        j                  dd      }d}t        |||       y )Nr   g      )bwriz)Integer input 'bwr=-6' gives wrong resultr   r   r   s       r   test_integer_bwrzTestGaussPulse.test_integer_bwrL  s7     ++H$?))(;
=
L'Br   c                     t        j                  dd      }t        j                  dd      }d}t        |||       y )Nr   g      N)tpriz*Integer input 'tpr=-60' gives wrong resultr   r   r   s       r   test_integer_tprzTestGaussPulse.test_integer_tprR  s7     ++H%@))(<
>
L'Br   N)r   r   r   r   r   r   r   r	   r   r   r   r   >  s    CCCCr   r   c                   $    e Zd Zd Zd Zd Zd Zy)TestUnitImpulsec           	          t        t        j                  d      t        j                  g d             t        t        j                  d      t        j                  g dg dg dg             y )N   )r)   r   r   r   r   r   r   r   r   )r)   r   r   r   r   r   r   r/   unit_impulser   asarrayr2   s    r   test_no_indexzTestUnitImpulse.test_no_index[  sM    	..q1

#:;	=	..v6

KI#FG	Ir   c           
      h   t        t        j                  dd      t        j                  g d             t        t        j                  dd      t        j                  g dg dg dg             t        j                  d	d
      }t        |t        j                  g dg dg dg dg             y )Nr   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   r2   imps     r   
test_indexzTestUnitImpulse.test_indexa  s    	..r15

#CD	F	..vv>

KI#FG	I $$VQ/RZZ)7)7)7)9 : 	;r   c           	          t        t        j                  dd      t        j                  g dg dg dg             t        t        j                  dd      t        j                  g d             y )Nr   midr   r   r   	   )	r   r   r   r   r   r   r   r   r   r   r   s    r   test_midzTestUnitImpulse.test_midn  sR    	..vu=

KI#FG	I	..q%8

#@A	Cr   c                    t        j                  d      }t        j                  |j                  t        j
                        sJ t        j                  ddt              }t        j                  |j                  t        j                        sJ t        j                  ddt              }t        j                  |j                  t        j                        sJ y )Nr   rz   r   dtype)rz   r   )r   r   )
r/   r   r   
issubdtyper   floatingintintegerrG   complexfloatingr   s     r   
test_dtypezTestUnitImpulse.test_dtypet  s    $$Q'}}SYY444$$Q5}}SYY

333$$VV7C}}SYY(:(:;;;r   N)r   r   r   r   r   r   r   r	   r   r   r   r   Y  s    I;C<r   r   c                       e Zd Zd Zy)TestSawtoothWaveformc                 D   t        j                  t        j                  dt        j                        t        j                  d            }|j
                  t        j                  k(  sJ t        j                  d      }|j
                  t        j                  k(  sJ y )Nr   r   )width)r/   sawtoothr   r   float32r   float64r2   waveforms     r   r   zTestSawtoothWaveform.test_dtype  sl    %%HHQbjj)A
 ~~+++%%a(~~+++r   Nr   r   r   r   r	   r   r   r   r     s    ,r   r   c                       e Zd Zd Zy)TestSquareWaveformc                 D   t        j                  t        j                  dt        j                        t        j                  d            }|j
                  t        j                  k(  sJ t        j                  d      }|j
                  t        j                  k(  sJ y )Nr   r   r   )duty)r/   squarer   r   r   r   r   r   s     r   r   zTestSquareWaveform.test_dtype  sh    ##BHHQbjj$A

SVX~~+++##A&~~+++r   Nr   r	   r   r   r   r     s    ,r   r   )T)numpyr   pytestr   r|   scipy._lib._array_apir   r   r   scipy.signal._waveformssignal
_waveformsr/   r   r   r   r   r%   r'   r   r   r   r   r   r	   r   r   <module>r      s}     *  , +


	GC GCTA AHC C6#< #<L, ,, ,r   