ó
    á“,j+  ã                   óú   • S r SSKrSSKrSSK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r  SSKJr  SSKJr   " S	 S
\R&                  R(                  R*                  5      r\S:X  a  SSKr\R2                  " 5         gg)zi
########
Features
########

See :class:`pyannote.core.SlidingWindowFeature` for the complete reference.
é    N)ÚTupleÚOptionalÚUnionÚIteratorÚListÚText)Ú	Alignmenté   )ÚSegment)ÚSlidingWindow)ÚTimelinec                   ó  • \ rS rSrSr S S\R                  S\S\\	   4S jjr
S r\S	 5       r\S
 5       rS rS rS rS\S\R                  4S jrS rS\\\R                  4   4S jrS r S!S\\   S\\\\R                  \4   \R                  4      4S jjr   S"S\\\4   S\S\\    S\S\\R                  S 4   4
S jjr!S r"\R                  \#RH                  4r%S\R                  4S jr&S r'S#S jr(Sr)g)$ÚSlidingWindowFeatureé1   z¼Periodic feature vectors

Parameters
----------
data : (n_frames, n_features) numpy array
sliding_window : SlidingWindow
labels : list, optional
    Textual description of each dimension.
NÚdataÚsliding_windowÚlabelsc                 ó6   • X l         Xl        X0l        SU l        g ©Néÿÿÿÿ)r   r   r   Ú_SlidingWindowFeature__i)Úselfr   r   r   s       Ú£C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\pyannote/core/feature.pyÚ__init__ÚSlidingWindowFeature.__init__<   s   € ð .<ÔØŒ	ØŒØˆ�ó    c                 ó4   • U R                   R                  S   $ )zNumber of feature vectorsr   ©r   Úshape©r   s    r   Ú__len__ÚSlidingWindowFeature.__len__D   s   € à�y‰y�‰˜qÑ!Ð!r   c                 óL   • U R                   R                  S[        U 5      5      $ )Nr   )r   Úrange_to_segmentÚlenr    s    r   ÚextentÚSlidingWindowFeature.extentH   s   € à×"Ñ"×3Ñ3°A´s¸4³yÓAÐAr   c                 ó4   • U R                   R                  S   $ )zDimension of feature vectorsr
   r   r    s    r   Ú	dimensionÚSlidingWindowFeature.dimensionL   s   € ð �y‰y�‰˜qÑ!Ð!r   c                 ój   • [         R                  " S[        5        U R                  R                  S   $ )Nz(This is deprecated in favor of `__len__`r   )ÚwarningsÚwarnÚDeprecationWarningr   r   r    s    r   Ú	getNumberÚSlidingWindowFeature.getNumberQ   s%   € Ü�ŠÐ@ÔBTÔUØ�y‰y�‰˜qÑ!Ð!r   c                 óP   • [         R                  " S[        5        U R                  $ )Nz3This is deprecated in favor of `dimension` property)r,   r-   r.   r)   r    s    r   ÚgetDimensionÚ!SlidingWindowFeature.getDimensionU   s    € Ü�ŠØAÔCUô	
ð �~‰~Ðr   c                 óP   • [         R                  " S[        5        U R                  $ )Nz0This is deprecated in favor of `extent` property)r,   r-   r.   r&   r    s    r   Ú	getExtentÚSlidingWindowFeature.getExtent[   s    € Ü�ŠØ>Ô@Rô	
ð �{‰{Ðr   ÚiÚreturnc                 ó    • U R                   U   $ )zGet ith feature vector©r   )r   r7   s     r   Ú__getitem__Ú SlidingWindowFeature.__getitem__a   s   € à�y‰y˜‰|Ðr   c                 ó   • SU l         U $ r   )r   r    s    r   Ú__iter__ÚSlidingWindowFeature.__iter__e   s   € ØˆŒØˆr   c                 óÊ   • U =R                   S-  sl          U R                  U R                      U R                  U R                      4$ ! [         a  n[	        5       eS nAff = f)Nr
   )r   r   r   Ú
IndexErrorÚStopIteration)r   Úes     r   Ú__next__ÚSlidingWindowFeature.__next__i   sS   € Ø�Š�A‰�ð	"Ø×&Ñ& t§x¡xÑ0°$·)±)¸D¿H¹HÑ2EÐEÐEøÜó 	"Ü“/Ð!ûð	"ús   —1A	 Á	
A"Á
AÁA"c                 ó"   • U R                  5       $ ©N)rD   r    s    r   ÚnextÚSlidingWindowFeature.nextp   s   € Ø�}‰}‹Ðr   Úwindowc              #   óÖ   #   • U R                   R                  S   n[        U5       H=  nU(       a"  U R                   U   U R                  U   4v •  M,  U R                   U   v •  M?     g7f)z·Feature vector iterator

Parameters
----------
window : bool, optional
    When True, yield both feature vector and corresponding window.
    Default is to only yield feature vector

r   N)r   r   Úranger   )r   rJ   Ú	n_samplesr7   s       r   ÚiterfeaturesÚ!SlidingWindowFeature.iterfeaturess   sW   é € ð —I‘I—O‘O AÑ&ˆ	Ü�yÖ!ˆAÞØ—i‘i ‘l D×$7Ñ$7¸Ñ$:Ð:Ô:à—i‘i ‘lÔ"ò	 "ùs   ‚A'A)ÚfocusÚmodeÚfixedÚreturn_datac           
      óÂ  • U(       d"  [        U[        5      (       d  Sn[        U5      eU(       d  Ub  Sn[        U5      eU R                  R	                  XUSS9nU R
                  R                  S   n[        U R
                  R                  5      S-
  n/ SSpºn	U Hc  u  pÍU
[        US5      [        US5      -
  -  n
U[        X×5      [        XÇ5      -
  -  nUS:  d  XÇ:¼  a  MH  U	[        US5      [        X×5      //-  n	Me     U	(       a>  [        R                  " U	 VVs/ s H  u  pÍU R
                  XÍ2SS24   PM     snn5      nO2SU R
                  R                  SS -   n[        R                  " U5      nUbn  [        R                  " [        R                  " U R
                  S   U
4S	U-  -   5      U[        R                  " U R
                  US-
     U4S	U-  -   5      /5      nU(       a  U$ [        U R                  U	S   S      R                  U R                  R                   U R                  R"                  S
9n[%        UUU R&                  S9$ s  snnf )a€  Extract frames

Parameters
----------
focus : Segment or Timeline
mode : {'loose', 'strict', 'center'}, optional
    In 'strict' mode, only frames fully included in 'focus' support are
    returned. In 'loose' mode, any intersecting frames are returned. In
    'center' mode, first and last frames are chosen to be the ones
    whose centers are the closest to 'focus' start and end times.
    Defaults to 'loose'.
fixed : float, optional
    Overrides `Segment` 'focus' duration and ensures that the number of
    returned frames is fixed (which might otherwise not be the case
    because of rounding errors).
return_data : bool, optional
    Return a numpy array (default). For `Segment` 'focus', setting it
    to False will return a `SlidingWindowFeature` instance.

Returns
-------
data : `numpy.ndarray` or `SlidingWindowFeature`
    Frame features.

See also
--------
SlidingWindow.crop

zG"focus" must be a "Segment" instance when "return_data"is set to False.Nz9"fixed" cannot be set when "return_data" is set to False.T)rQ   rR   Úreturn_rangesr   r
   )r   )r
   )ÚstartÚdurationÚstep©r   )Ú
isinstancer   Ú
ValueErrorr   Úcropr   r   r%   ÚminÚmaxÚnpÚvstackÚemptyÚtiler   rV   rW   rX   r   r   )r   rP   rQ   rR   rS   ÚmsgÚrangesrM   Ún_dimensionsÚclipped_rangesÚrepeat_firstÚrepeat_lastrV   Úendr   r   r   s                    r   r\   ÚSlidingWindowFeature.crop†   s@  € öJ ¤j°¼×&@Ñ&@ð#ð ô ˜S“/Ð!æ %Ñ"3ØMˆCÜ˜S“/Ð!à×$Ñ$×)Ñ)Ø E¸ð *ð 
ˆð
 —I‘I—O‘O AÑ&ˆ	ô
 ˜4Ÿ9™9Ÿ?™?Ó+¨aÑ/ˆð 57¸¸1 kˆÛ ‰JˆEàœC  Q›K¬#¨e°Q«-Ñ7Ñ7ˆLàœ3˜sÓ.´°UÓ1FÑFÑFˆKà�Q‹w˜%Ó,Ùð ¤C¨¨q£M´3°sÓ3FÐ#GÐ"HÑH’ñ !ö Ü—9’9ÉÔWÊ¹*¸%˜dŸi™i¨¨	²1¨Ô5ÉÒWÓX‰Dð ˜4Ÿ9™9Ÿ?™?¨1¨2Ð.Ñ.ˆEÜ—8’8˜E“?ˆDð ÑÜ—9’9ô —G’G˜DŸI™I a™L¨<¨/¸DÀ<Ñ<OÑ*OÓPØä—G’GØŸ	™	 )¨a¡-Ñ0°;°.À4È,ÑCVÑ2Vóðó
ˆDö ØˆKô 'Ø×%Ñ% n°QÑ&7¸Ñ&:Ñ;×AÑAØ×(Ñ(×1Ñ1Ø×$Ñ$×)Ñ)ñ
ˆô $ D¨.ÀÇÁÑMÐMùóA Xs   Ä! I
c                 ó¬   • SSK JnJn  U(       d8  [        R                  " UR                  U R                  R                  S95        g SSK Jn  U" U 5      $ )Nr
   )ÚMATPLOTLIB_IS_AVAILABLEÚMATPLOTLIB_WARNING)Úklass)Úrepr_feature)	Únotebookrl   rm   r,   r-   ÚformatÚ	__class__Ú__name__ro   )r   rl   rm   ro   s       r   Ú
_repr_png_ÚSlidingWindowFeature._repr_png_ó   s>   € ßIæ&Ü�MŠMÐ,×3Ñ3¸$¿.¹.×:QÑ:QÐ3ÐRÔSØå*á˜DÓ!Ð!r   c                 ó   • U R                   $ rG   r:   r    s    r   Ú	__array__ÚSlidingWindowFeature.__array__   s   € Ø�y‰yÐr   c                 ó¸  ^ • UR                  SS5      nX5-    H.  n[        UT R                  [        4-   5      (       a  M(  [        s  $    [        S U 5       5      nU(       a  [        S U 5       5      US'   [        X5      " U0 UD6n[        U5      [
        L a  [        U 4S jU 5       5      $ US:X  a  g [        T 5      " UT R                  T R                  S9$ )NÚout© c              3   óh   #   • U  H(  n[        U[        5      (       a  UR                  OUv •  M*     g 7frG   ©rZ   r   r   ©Ú.0Úxs     r   Ú	<genexpr>Ú7SlidingWindowFeature.__array_ufunc__.<locals>.<genexpr>  s)   é € ð 
ÚJPÀQ”j Ô$8×9Ñ9ˆA�FŠF¸qÔ@Ê&ùó   ‚02c              3   óh   #   • U  H(  n[        U[        5      (       a  UR                  OUv •  M*     g 7frG   r}   r~   s     r   r�   r‚     s)   é € ð "ÚNQÈœ* QÔ(<×=Ñ=�—’À1ÔDÊcùrƒ   c              3   ón   >#   • U  H*  n[        T5      " UTR                  TR                  S 9v •  M,     g7f)rY   N)Útyper   r   )r   r€   r   s     €r   r�   r‚     s,   øé € ð ÚPTÈ1”�T”
˜1˜d×1Ñ1¸$¿+¹+ÖFÒPTùs   ƒ25ÚatrY   )
ÚgetrZ   Ú_HANDLED_TYPESr   ÚNotImplementedÚtupleÚgetattrr†   r   r   )r   ÚufuncÚmethodÚinputsÚkwargsrz   r€   r   s   `       r   Ú__array_ufunc__Ú$SlidingWindowFeature.__array_ufunc__  sã   ø€ Ø�j‰j˜ Ó#ˆØ”ˆAô
 ˜a ×!4Ñ!4Ô8LÐ7NÑ!N×OÓOÜ%Ò%ñ ô ñ 
ÙJPó
ó 
ˆö Ü!ñ "ÙNQó"ó ˆF�5‰Mô �uÔ% vÐ8°Ñ8ˆä�‹:œÒäô ÙPTóó ð ð �t‹^àô ˜”:˜d D×$7Ñ$7ÀÇÁÑLÐLr   c           
      óÎ  • U R                   R                  nU R                   R                  nU R                   R                  n[	        U 5      nUSU-  -   [
        R                  " U5      U-  -   nUR                   R                  nUR                   R                  nUR                   R                  n	[	        U5      n
USU	-  -   [
        R                  " U
5      U-  -   n[
        R                  " U R                  R                   Vs/ s H/  n[
        R                  " X¶U5      SS2[
        R                  4   PM1     sn5      n[        XÑR                   U R                  S9$ s  snf )zÂAlign features by linear temporal interpolation

Parameters
----------
to : SlidingWindowFeature
    Features to align with.

Returns
-------
aligned : SlidingWindowFeature
    Aligned features
g      à?NrY   )r   rV   rX   rW   r%   r_   ÚarangeÚhstackr   ÚTÚinterpÚnewaxisr   r   )r   ÚtoÚ	old_startÚold_stepÚold_durationÚold_samplesÚold_tÚ	new_startÚnew_stepÚnew_durationÚnew_samplesÚnew_tÚold_dataÚnew_datas                 r   ÚalignÚSlidingWindowFeature.align#  s)  € ð ×'Ñ'×-Ñ-ˆ	Ø×&Ñ&×+Ñ+ˆØ×*Ñ*×3Ñ3ˆÜ˜$“iˆØ˜C ,Ñ.Ñ.´·²¸;Ó1GÈ(Ñ1RÑRˆà×%Ñ%×+Ñ+ˆ	Ø×$Ñ$×)Ñ)ˆØ×(Ñ(×1Ñ1ˆÜ˜"“gˆØ˜C ,Ñ.Ñ.´·²¸;Ó1GÈ(Ñ1RÑRˆä—9’9ð !%§	¡	§¢óâ +�Hô —	’	˜%¨Ó1²!´R·Z±Z°-Ô@Ù +ñó
ˆô $ H×.?Ñ.?ÈÏÉÑTÐTùòs   Ä6E")Ú__ir   r   r   rG   )F)ÚlooseNT)r™   r   r8   r   )*rs   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r_   Úndarrayr   r   r   r   r!   Úpropertyr&   r)   r/   r2   r5   Úintr;   r>   r   r   rD   rH   r   Úboolr   r   rN   r   r	   Úfloatr\   rt   ÚnumbersÚNumberr‰   rw   r‘   r¦   Ú__static_attributes__r{   r   r   r   r   1   s‹  † ñð UYñØ—J‘JðØ0=ðØGKÈDÁzõò"ð ñBó ðBð ñ"ó ð"ò"òòð˜Sð  R§Z¡Zô òð"˜% ¨¯©Ð 3Ñ4ô "òð (-ñ#Ø˜t‘nð#à	�%˜˜bŸj™j¨'Ð1Ñ2°B·J±JÐ>Ñ?Ñ	@õ#ð, "Ø!%Ø ñkNà�W˜hÐ&Ñ'ðkNð ðkNð ˜‰ð	kNð
 ðkNð 
ˆr�z‰zÐ1Ð1Ñ	2õkNòZ	"ð —j‘j '§.¡.Ð1€Nð˜2Ÿ:™:ô òM÷@ Ur   r   Ú__main__)r­   r³   r,   Útypingr   r   r   r   r   r   Únumpyr_   Úpyannote.core.utils.typesr	   Úsegmentr   r   Útimeliner   ÚlibÚmixinsÚNDArrayOperatorsMixinr   rs   ÚdoctestÚtestmodr{   r   r   Ú<module>rÁ      sb   ðñ<ó Û ß ?× ?ã å /Ý Ý "Ý ôRU˜2Ÿ6™6Ÿ=™=×>Ñ>ô RUðj ˆzÓÛà‡O‚OÕð r   