+
    LV-j$8  ã                   óš   € ^ RI Ht ^ RIHt ^ RIHtHtHt ^ RI	H
u Ht ^ RIHt ^ RIHt ^RIHt RRRR	R/R
 lltR tR tR tRR ltR# )é    )Úfloat_factorial)Únumpy)Úarray_namespaceÚxp_swapaxesÚ	xp_deviceN)Ú
convolve1d)Ú
_polyutils)Ú
axis_sliceÚxpÚdevicec               óP  € W8¼  d   \        R4      h\        V ^4      w  r‰Vf   V	^ 8X  d   VR,
          pMTp^ Tu;8:  d   V 8  g   M \        R4      hVR9  d   \        R4      hVf   \        M\        VP	                  ^ 4      4      pW!8”  d    VP                  WP                  VR7      p
V
# VP                  V) W,
          VP                  VR7      pVR8X  d   VP                  V4      pVP                  VP                  V^,           VP                  VR7      R	4      pW¼,          pVP                  V^,           VP                  VR7      p\        P                  ! Wâ4      P                  \        V4      W2,          ,          4      p\        P                  ! WÞVR7      w  p
  pV
# )
a
  Compute the coefficients for a 1-D Savitzky-Golay FIR filter.

Parameters
----------
window_length : int
    The length of the filter window (i.e., the number of coefficients).
polyorder : int
    The order of the polynomial used to fit the samples.
    `polyorder` must be less than `window_length`.
deriv : int, optional
    The order of the derivative to compute. This must be a
    nonnegative integer. The default is 0, which means to filter
    the data without differentiating.
delta : float, optional
    The spacing of the samples to which the filter will be applied.
    This is only used if deriv > 0.
pos : int or None, optional
    If pos is not None, it specifies evaluation position within the
    window. The default is the middle of the window.
use : str, optional
    Either 'conv' or 'dot'. This argument chooses the order of the
    coefficients. The default is 'conv', which means that the
    coefficients are ordered to be used in a convolution. With
    use='dot', the order is reversed, so the filter is applied by
    dotting the coefficients with the data set.

Returns
-------
coeffs : 1-D ndarray
    The filter coefficients.

See Also
--------
savgol_filter

Notes
-----
.. versionadded:: 0.14.0

References
----------
A. Savitzky, M. J. E. Golay, Smoothing and Differentiation of Data by
Simplified Least Squares Procedures. Analytical Chemistry, 1964, 36 (8),
pp 1627-1639.
Jianwen Luo, Kui Ying, and Jing Bai. 2005. Savitzky-Golay smoothing and
differentiation filter for even number data. Signal Process.
85, 7 (July 2005), 1429-1434.

Examples
--------
>>> import numpy as np
>>> from scipy.signal import savgol_coeffs
>>> savgol_coeffs(5, 2)
array([-0.08571429,  0.34285714,  0.48571429,  0.34285714, -0.08571429])
>>> savgol_coeffs(5, 2, deriv=1)
array([ 2.00000000e-01,  1.00000000e-01,  2.07548111e-16, -1.00000000e-01,
       -2.00000000e-01])

Note that use='dot' simply reverses the coefficients.

>>> savgol_coeffs(5, 2, pos=3)
array([ 0.25714286,  0.37142857,  0.34285714,  0.17142857, -0.14285714])
>>> savgol_coeffs(5, 2, pos=3, use='dot')
array([-0.14285714,  0.17142857,  0.34285714,  0.37142857,  0.25714286])
>>> savgol_coeffs(4, 2, pos=3, deriv=1, use='dot')
array([0.45,  -0.85,  -0.65,  1.05])

`x` contains data from the parabola x = t**2, sampled at
t = -1, 0, 1, 2, 3.  `c` holds the coefficients that will compute the
derivative at the last position.  When dotted with `x` the result should
be 6.

>>> x = np.array([1, 0, 1, 4, 9])
>>> c = savgol_coeffs(5, 2, pos=4, deriv=1, use='dot')
>>> c.dot(x)
6.0
z*polyorder must be less than window_length.g      à?z4pos must be nonnegative and less than window_length.Úconvz`use` must be 'conv' or 'dot'©Údtyper   ©r   )r   Údot©éÿÿÿÿé   )Ú
ValueErrorÚdivmodÚ	np_compatr   ÚemptyÚzerosÚfloat64ÚarangeÚflipÚreshapeÚxpxÚatÚsetr   Ú_puÚ_lstsq)Úwindow_lengthÚ	polyorderÚderivÚdeltaÚposÚuser   r   ÚhalflenÚremÚcoeffsÚxÚorderÚAÚyÚ_s   &&&&&&$$        Úm/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/scipy/signal/_savitzky_golay.pyÚsavgol_coeffsr3      s{  € ðx Ô!ÜÐEÓFÐFä˜-¨Ó+�L€Gà
‚{Ø�!Œ8Ø˜C•-‰CàˆCà�Ö$�}Ö$Üð *ó +ð 	+ð �/Ô!ÜÐ8Ó9Ð9ð ’j�¤o°b·h±h¸q³kÓ&B€BàÔØ—‘˜-¯z©zÀ&�ÓIˆØˆð 	�	‰	�3�$˜Õ+°2·:±:Àfˆ	ÓM€Aà
ˆf„}à�G‰G�A‹Jˆà�J‰JØ
�	‰	�)˜a•- r§z¡z¸&ˆ	ÓAÀ7ó€Eð 	
�
€Að 	�‰�˜Q• b§j¡j¸ˆÓ@€Aô 	�ŠˆqÓ×Ñœ_¨UÓ3°uµ~ÕFÓG€Aô —j’j ¨"Ô-�O€FˆAˆq�!à€Mó    c          
     óê  € V^ 8X  d   T pV# V P                   ^ ,          pWA8:  d   VP                  V R,          4      pV# VP                  V RV) 1R3,          RR7      p\        V4       F„  pVP	                  WF,
          ^,
          W,
          ^,
          RV P
                  \        V 4      R7      pWRP                  WtV,
          3RV P                  ^,
          ,          ,           4      ,          pK†  	  TpV# )	a4  Differentiate polynomials represented with coefficients.

p must be a 1-D or 2-D array.  In the 2-D case, each column gives
the coefficients of a polynomial; the first row holds the coefficients
associated with the highest power. m must be a nonnegative integer.
(numpy.polyder doesn't handle the 2-D case.)
.NT)Úcopyr   ):Nr   N.r   )r   )	ÚshapeÚ
zeros_likeÚasarrayÚranger   r   r   r   Úndim)ÚpÚmr   ÚresultÚnÚdpÚkÚrngs   &&$     r2   Ú_polyderrC   ›   sÝ   € ð 	ˆA„vØˆð €Mð �G‰G�A�JˆØŒ6Ø—]‘] 1 W¥:Ó.ˆFð €Mð —‘˜A˜c ˜r˜c 3˜h�K¨d�Ó3ˆBÜ˜1–X�Ø—i‘iØ•E˜A•I˜q�u q�y¨"°A·G±GÄIÈaÃLð  ó �ð —j‘j ¨1¥u h°¸¿¹À!½Õ1DÕ&DÓEÕE’ñ	 ð
 ˆFØ€Mr4   c
           
     óÚ  € \        V 4      p
\        WW%R7      pV^ 8X  g   WPP                  ) 8X  d   TpRpM\        Wµ^ V
4      pRpV
P	                  WÌP
                  ^ ,          R34      p\        P                  ! V
P                  ^ W!,
          V P                  \        V 4      R7      WÆV
R7      pV^ 8”  d   \        WçV
R7      pV
P                  W1,
          WA,
          VP                  \        V4      R7      p\        P                  ! WêP	                  VR	4      V
R7      W‡,          ,          p\        V	P
                  4      pVV,          V^ ,          uV^ &   VV&   V
P	                  VWC,
          .VR,          O54      pV'       d   \        V^ WZ4      p\        R4      .V	P                  ,          p\        W44      VV&   \        P                   ! V	\#        V4      4      P%                  V4      p	V	# )
a-  
Given an N-d array `x` and the specification of a slice of `x` from
`window_start` to `window_stop` along `axis`, create an interpolating
polynomial of each 1-D slice, and evaluate that polynomial in the slice
from `interp_start` to `interp_stop`. Put the result into the
corresponding slice of `y`.
)ÚstartÚstopÚaxisFTr   r   :r   NNNr   r   )r   r
   r;   r   r   r7   r"   Úpolyfitr   r   r   rC   ÚpolyvalÚlistÚslicer   r    Útupler!   )r-   Úwindow_startÚwindow_stopÚinterp_startÚinterp_stoprG   r%   r&   r'   r0   r   Úx_edgeÚxx_edgeÚswappedÚpoly_coeffsÚiÚvaluesÚshpÚy_slices   &&&&&&&&&&         r2   Ú	_fit_edgerY   µ   sª  € ô 
˜Ó	€Bô ˜°KÔK€FØˆq„y�DŸV™V˜G”OØˆØ‰ä˜f¨A¨rÓ2ˆØˆØ�j‰j˜§=¡=°Õ#3°RÐ"8Ó9€Gô —+’+Ø
�	‰	Øˆ{Õ)°·±ÄÈ1Ãð 	ó 	
à "ô€Kð ˆq„yÜ˜{°bÔ9ˆð 	�	‰	ØÕ# [Õ%?Ø×Ñ¬	°+Ó(>ð 	ó 	€Aô �[Š[˜§j¡j°°GÓ&<ÀÔDÈÍÕW€Fô ˆq�w‰w‹-€CØ˜D�	 3 q¥6Ð€Cˆ�FˆC�‰IØ�Z‰Z˜ Õ!;Ð F¸cÀ"½gÑ FÓG€FßÜ˜V Q¨Ó1ˆä�T‹{ˆm˜aŸf™fÕ$€GÜ˜,Ó4€GˆD�MÜ�Šˆq”%˜“.Ó!×%Ñ% fÓ-€Aà€Hr4   c                óš   € V^,          p\        V ^ V^ WuW#WF4
      pV P                  V,          p\        WV,
          WˆV,
          W…W#WF4
      pV# )z¶
Use polynomial interpolation of x at the low and high ends of the axis
to fill in the halflen values in y.

This function just calls _fit_edge twice, once for each end of the axis.
)rY   r7   )	r-   r$   r%   r&   r'   rG   r0   r*   r?   s	   &&&&&&&  r2   Ú_fit_edges_polyfitr[   ì   sY   € ð ˜qÕ €GÜ�!�Q˜ q¨'Ø ó	*€Aà	�‰��€AÜ�!˜Õ&¨¨w­;¸Ø ó	*€Að €Hr4   c           
     óÞ  € VR9  d   \        R4      h\        V 4      pVP                  V 4      p V P                  VP                  8w  d7   V P                  VP
                  8w  d   VP                  WP                  4      p \        WW4V\        V 4      R7      p	VR8X  dA   WP                  V,          8”  d   \        R4      h\        W	VRR7      p
\        WW#WEV
4      p
V
# \        W	WVVR7      p
V
# )	a9  Apply a Savitzky-Golay filter to an array.

This is a 1-D filter. If `x`  has dimension greater than 1, `axis`
determines the axis along which the filter is applied.

Parameters
----------
x : array_like
    The data to be filtered. If `x` is not a single or double precision
    floating point array, it will be converted to type ``numpy.float64``
    before filtering.
window_length : int
    The length of the filter window (i.e., the number of coefficients).
    If `mode` is 'interp', `window_length` must be less than or equal
    to the size of `x`.
polyorder : int
    The order of the polynomial used to fit the samples.
    `polyorder` must be less than `window_length`.
deriv : int, optional
    The order of the derivative to compute. This must be a
    nonnegative integer. The default is 0, which means to filter
    the data without differentiating.
delta : float, optional
    The spacing of the samples to which the filter will be applied.
    This is only used if deriv > 0. Default is 1.0.
axis : int, optional
    The axis of the array `x` along which the filter is to be applied.
    Default is -1.
mode : str, optional
    Must be 'mirror', 'constant', 'nearest', 'wrap' or 'interp'. This
    determines the type of extension to use for the padded signal to
    which the filter is applied.  When `mode` is 'constant', the padding
    value is given by `cval`.  See the Notes for more details on 'mirror',
    'constant', 'wrap', and 'nearest'.
    When the 'interp' mode is selected (the default), no extension
    is used.  Instead, a degree `polyorder` polynomial is fit to the
    last `window_length` values of the edges, and this polynomial is
    used to evaluate the last `window_length // 2` output values.
cval : scalar, optional
    Value to fill past the edges of the input if `mode` is 'constant'.
    Default is 0.0.

Returns
-------
y : ndarray, same shape as `x`
    The filtered data.

See Also
--------
savgol_coeffs

Notes
-----
Details on the `mode` options:

    'mirror':
        Repeats the values at the edges in reverse order. The value
        closest to the edge is not included.
    'nearest':
        The extension contains the nearest input value.
    'constant':
        The extension contains the value given by the `cval` argument.
    'wrap':
        The extension contains the values from the other end of the array.

For example, if the input is [1, 2, 3, 4, 5, 6, 7, 8], and
`window_length` is 7, the following shows the extended data for
the various `mode` options (assuming `cval` is 0)::

    mode       |   Ext   |         Input          |   Ext
    -----------+---------+------------------------+---------
    'mirror'   | 4  3  2 | 1  2  3  4  5  6  7  8 | 7  6  5
    'nearest'  | 1  1  1 | 1  2  3  4  5  6  7  8 | 8  8  8
    'constant' | 0  0  0 | 1  2  3  4  5  6  7  8 | 0  0  0
    'wrap'     | 6  7  8 | 1  2  3  4  5  6  7  8 | 1  2  3

.. versionadded:: 0.14.0

Examples
--------
>>> import numpy as np
>>> from scipy.signal import savgol_filter
>>> np.set_printoptions(precision=2)  # For compact display.
>>> x = np.array([2, 2, 5, 2, 1, 0, 1, 4, 9])

Filter with a window length of 5 and a degree 2 polynomial.  Use
the defaults for all other parameters.

>>> savgol_filter(x, 5, 2)
array([1.66, 3.17, 3.54, 2.86, 0.66, 0.17, 1.  , 4.  , 9.  ])

Note that the last five values in x are samples of a parabola, so
when mode='interp' (the default) is used with polyorder=2, the last
three values are unchanged. Compare that to, for example,
`mode='nearest'`:

>>> savgol_filter(x, 5, 2, mode='nearest')
array([1.74, 3.03, 3.54, 2.86, 0.66, 0.17, 1.  , 4.6 , 7.97])

ÚconstantÚinterpz@mode must be 'mirror', 'constant', 'nearest' 'wrap' or 'interp'.)r&   r'   r   r   zOIf mode is 'interp', window_length must be less than or equal to the size of x.)rG   Úmode)rG   r_   Úcval)Úmirrorr]   Únearestr^   Úwrap)r   r   r9   r   r   Úfloat32Úastyper3   r   r7   r   r[   )r-   r$   r%   r&   r'   rG   r_   r`   r   r,   r0   s   &&&&&&&&   r2   Úsavgol_filterrf   ý   së   € ðL ÐFÔFÜð /ó 0ð 	0ô 
˜Ó	€BØ
�
‰
�1‹€Aà‡w�w�"—*‘*Ô §¡¨B¯J©JÔ!6Ø�I‰I�aŸ™Ó$ˆäØ¨¸rÌ)ÐTUË,ô€Fð ˆxÔØŸ7™7 4�=Ô(Üð ?ó @ð @ô �q t°*Ô=ˆÜ˜q°À5ÐPQÓRˆð
 €Hô �q t¸TÔBˆà€Hr4   )r   ç      ð?Nr   )r   rg   r   r^   g        )Úscipy._lib._utilr   Úscipy._lib.array_api_compatr   r   Úscipy._lib._array_apir   r   r   Úscipy._lib.array_api_extraÚ_libÚarray_api_extrar   Úscipy.ndimager   Úscipy.signalr	   r"   Ú_arraytoolsr
   r3   rC   rY   r[   rf   © r4   r2   Ú<module>rr      sO   ðÝ ,Ý :ß IÑ Iß (Ð (å $Ý *Ý #ñMØ$(ðMØ15õMò`ò43ònö"Br4   