+
    xȇi?Z                    b   R t ^ RIHt ^ RIHt ^ RIt^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ]! R
4       ! R R4      4       t ! R R]4      t ! R R]4      t]! R
4       ! R R]4      4       t ! R R]4      t]! R
4       ! R R]4      4       t ! R R]4      t ! R R]4      tR# )zLIndexer objects for computing start/end window bounds for rolling operations)annotations)	timedeltaN)
BaseOffset) calculate_variable_window_bounds)
set_module)ensure_platform_int)DatetimeIndex)Nanozpandas.api.indexersc                  :    ] tR t^tRtRR R lltR	R R lltRtR# )
BaseIndexera  
Base class for window bounds calculations.

Parameters
----------
index_array : np.ndarray, default None
    Array-like structure representing the indices for the data points.
    If None, the default indices are assumed. This can be useful for
    handling non-uniform indices in data, such as in time series
    with irregular timestamps.
window_size : int, default 0
    Size of the moving window. This is the number of observations used
    for calculating the statistic. The default is to consider all
    observations within the window.
**kwargs
    Additional keyword arguments passed to the subclass's methods.

See Also
--------
DataFrame.rolling : Provides rolling window calculations on dataframe.
Series.rolling : Provides rolling window calculations on series.

Examples
--------
>>> from pandas.api.indexers import BaseIndexer
>>> class CustomIndexer(BaseIndexer):
...     def get_window_bounds(self, num_values, min_periods, center, closed, step):
...         start = np.arange(num_values, dtype=np.int64)
...         end = np.arange(num_values, dtype=np.int64) + self.window_size
...         return start, end
>>> df = pd.DataFrame({"values": range(5)})
>>> indexer = CustomIndexer(window_size=2)
>>> df.rolling(indexer).sum()
    values
0   1.0
1   3.0
2   5.0
3   7.0
4   4.0
Nc               $    V ^8  d   QhRRRRRR/# )   index_arraynp.ndarray | Nonewindow_sizeintreturnNone )formats   "l/Users/max/.openclaw/workspace/postharvest/venv/lib/python3.14/site-packages/pandas/core/indexers/objects.py__annotate__BaseIndexer.__annotate__?   s$     & &,&BE&	&    c                	h    Wn         W n        VP                  4        F  w  rE\        WV4       K  	  R # )N)r   r   itemssetattr)selfr   r   kwargskeyvalues   &&&,  r   __init__BaseIndexer.__init__?   s,     '& ,,.JCDu% )r   c               0    V ^8  d   QhRRRRRRRRR	RR
R/# r   
num_valuesr   min_periodsz
int | Nonecenterzbool | Noneclosedz
str | Nonestepr   ztuple[np.ndarray, np.ndarray]r   )r   s   "r   r   r   H   sF     !" !"!"  !" 	!"
 !" !" 
'!"r   c                    \         h  
Computes the bounds of a window.

Parameters
----------
num_values : int, default 0
    number of values that will be aggregated over
window_size : int, default 0
    the number of rows in a window
min_periods : int, default None
    min_periods passed from the top level rolling API
center : bool, default None
    center passed from the top level rolling API
closed : str, default None
    closed passed from the top level rolling API
step : int, default None
    step passed from the top level rolling API
win_type : str, default None
    win_type passed from the top level rolling API

Returns
-------
A tuple of ndarray[int64]s, indicating the boundaries of each
window
)NotImplementedErrorr   r%   r&   r'   r(   r)   s   &&&&&&r   get_window_boundsBaseIndexer.get_window_boundsH   s    B "!r   )r   r   )N    r1   NNNN)__name__
__module____qualname____firstlineno____doc__r!   r/   __static_attributes__r   r   r   r   r      s    'R&!" !"r   r   c                  *    ] tR t^ltRtRR R lltRtR# )FixedWindowIndexerz3Creates window boundaries that are of fixed length.Nc               0    V ^8  d   QhRRRRRRRRR	RR
R/# r$   r   )r   s   "r   r   FixedWindowIndexer.__annotate__o   sF     0 00  0 	0
 0 0 
'0r   c                   V'       g   V P                   ^ 8X  d   V P                   ^,
          ^,          pM^ p\        P                  ! ^V,           V^,           V,           VRR7      pWpP                   ,
          pVR9   d
   V^,          pVR9   d
   V^,          p\        P                  ! V^ V4      p\        P                  ! V^ V4      pW3# )r,   int64dtypeleftboth)rB   neither)r   nparangeclip)	r   r%   r&   r'   r(   r)   offsetendstarts	   &&&&&&   r   r/   $FixedWindowIndexer.get_window_boundso   s    B T%%*&&*q0FFiiF
JNV$;TQ&&&%%QJE((1HCggc1j)q*-zr   r   r2   r3   r4   r5   r6   r7   r/   r8   r   r   r   r:   r:   l   s    =0 0r   r:   c                  *    ] tR t^tRtRR R lltRtR# )VariableWindowIndexerzNCreates window boundaries that are of variable length, namely for time series.Nc               0    V ^8  d   QhRRRRRRRRR	RR
R/# r$   r   )r   s   "r   r   "VariableWindowIndexer.__annotate__   sF     ,
 ,
,
  ,
 	,

 ,
 ,
 
',
r   c                J    \        VV P                  VVVV P                  4      # r+   )r   r   r   r.   s   &&&&&&r   r/   'VariableWindowIndexer.get_window_bounds   s0    J 0
 	
r   r   r2   rL   r   r   r   rN   rN      s    X,
 ,
r   rN   c                  F   a  ] tR t^tRtRR V 3R llltRR R lltRtV ;t# )	VariableOffsetWindowIndexera  
Calculate window boundaries based on a non-fixed offset such as a BusinessDay.

Parameters
----------
index_array : np.ndarray, default 0
    Array-like structure specifying the indices for data points.
    This parameter is currently not used.

window_size : int, optional, default 0
    Specifies the number of data points in each window.
    This parameter is currently not used.

index : DatetimeIndex, optional
    ``DatetimeIndex`` of the labels of each observation.

offset : BaseOffset, optional
    ``DateOffset`` representing the size of the window.

**kwargs
    Additional keyword arguments passed to the parent class ``BaseIndexer``.

See Also
--------
api.indexers.BaseIndexer : Base class for all indexers.
DataFrame.rolling : Rolling window calculations on DataFrames.
offsets : Module providing various time offset classes.

Examples
--------
>>> from pandas.api.indexers import VariableOffsetWindowIndexer
>>> df = pd.DataFrame(range(10), index=pd.date_range("2020", periods=10))
>>> offset = pd.offsets.BDay(1)
>>> indexer = VariableOffsetWindowIndexer(index=df.index, offset=offset)
>>> df
            0
2020-01-01  0
2020-01-02  1
2020-01-03  2
2020-01-04  3
2020-01-05  4
2020-01-06  5
2020-01-07  6
2020-01-08  7
2020-01-09  8
2020-01-10  9
>>> df.rolling(indexer).sum()
               0
2020-01-01   0.0
2020-01-02   1.0
2020-01-03   2.0
2020-01-04   3.0
2020-01-05   7.0
2020-01-06  12.0
2020-01-07   6.0
2020-01-08   7.0
2020-01-09   8.0
2020-01-10   9.0
c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r   r   r   r   r   indexzDatetimeIndex | NonerH   zBaseOffset | Noner   r   r   )r   s   "r   r   (VariableOffsetWindowIndexer.__annotate__  s<      &  $	
 " 
r   c                	   < \         SV `  ! W3/ VB  \        V\        4      '       g   \	        R 4      hW0n        \        V\        4      '       g   \	        R4      hW@n        R# )zindex must be a DatetimeIndex.z(offset must be a DateOffset-like object.N)superr!   
isinstancer   
ValueErrorrV   r   rH   )r   r   r   rV   rH   r   	__class__s   &&&&&,r   r!   $VariableOffsetWindowIndexer.__init__  sS     	<V<%//=>>
&*--GHHr   c               0    V ^8  d   QhRRRRRRRRR	RR
R/# r$   r   )r   s   "r   r   rW   "  sN     c cc  c 	c
 c c 
'cr   c                   Ve   \        R4      hV^ 8:  d1   \        P                  ! ^ RR7      \        P                  ! ^ RR7      3# Vf   V P                  e   RMRpVR9   pVR9   pV P                  V^,
          ,          V P                  ^ ,          8  d   RpM^pWP                  ,          p	\        P                  ! VRR7      p
V
P                  R4       \        P                  ! VRR7      pVP                  R4       ^ V
^ &   V'       d   ^V^ &   M^ V^ &   \        ^ 4      p\        ^V4       EF$  pV P                  V,          pW,
          pV'       d   V\        ^4      ,          pWV&   \        W^,
          ,          V4       F1  pV P                  V,          V,
          V,          pVV8  g   K-  VW&    M	  V P                  W^,
          ,          ,          V,
          V,          pVV8X  d"   V'       g   W^,
          ,          ^,           W&   M$VV8:  d   V^,           W&   MW^,
          ,          W&   V'       d   EK  W;;,          ^,          uu&   EK'  	  W3# )	r,   z/step not implemented for variable offset windowr>   r?   rightrC   )r`   rC   rA   )	r-   rE   emptyrV   rH   fillr   ranger	   )r   r%   r&   r'   r(   r)   right_closedleft_closedindex_growth_signoffset_diffrJ   rI   zeroi	end_boundstart_boundj
start_diffend_diffs   &&&&&&             r   r/   -VariableOffsetWindowIndexer.get_window_bounds"  s   B %&WXX?88AW-rxx/III > $

 6WFF!22 00::j1n%

15 " !'++573

2hhz1a CF CF| q*%A

1I#1K tAw& !H5Q<+"jjmk9=NN
$ EH	 , 

31u:.:>OOH4UaT!QU  <!; &> zr   )rV   rH   )Nr1   NNr2   )	r3   r4   r5   r6   r7   r!   r/   r8   __classcell__r\   s   @r   rT   rT      s    :x  c cr   rT   c                  *    ] tR tRtRtRR R lltRtR# )ExpandingIndexeri  z;Calculate expanding window bounds, mimicking df.expanding()Nc               0    V ^8  d   QhRRRRRRRRR	RR
R/# r$   r   )r   s   "r   r   ExpandingIndexer.__annotate__  sF     $
 $
$
  $
 	$

 $
 $
 
'$
r   c                    \         P                  ! V\         P                  R7      \         P                  ! ^V^,           \         P                  R7      3# r,   r?   )rE   zerosr>   rF   r.   s   &&&&&&r   r/   "ExpandingIndexer.get_window_bounds  s9    D HHZrxx0IIaarxx8
 	
r   r   r2   rL   r   r   r   rt   rt     s    E$
 $
r   rt   c                  *    ] tR tRtRtRR R lltRtR# )FixedForwardWindowIndexeri  a^  
Creates window boundaries for fixed-length windows that include the current row.

Parameters
----------
index_array : np.ndarray, default None
    Array-like structure representing the indices for the data points.
    If None, the default indices are assumed. This can be useful for
    handling non-uniform indices in data, such as in time series
    with irregular timestamps.
window_size : int, default 0
    Size of the moving window. This is the number of observations used
    for calculating the statistic. The default is to consider all
    observations within the window.
**kwargs
    Additional keyword arguments passed to the subclass's methods.

See Also
--------
DataFrame.rolling : Provides rolling window calculations.
api.indexers.VariableWindowIndexer : Calculate window bounds based on
    variable-sized windows.

Examples
--------
>>> df = pd.DataFrame({"B": [0, 1, 2, np.nan, 4]})
>>> df
     B
0  0.0
1  1.0
2  2.0
3  NaN
4  4.0

>>> indexer = pd.api.indexers.FixedForwardWindowIndexer(window_size=2)
>>> df.rolling(window=indexer, min_periods=1).sum()
     B
0  1.0
1  3.0
2  2.0
3  4.0
4  4.0
Nc               0    V ^8  d   QhRRRRRRRRR	RR
R/# r$   r   )r   s   "r   r   &FixedForwardWindowIndexer.__annotate__  sF     / //  / 	/
 / / 
'/r   c                   V'       d   \        R4      hVe   \        R4      hVf   ^p\        P                  ! ^ WRR7      pW`P                  ,           pV P                  '       d   \        P                  ! V^ V4      pWg3# )r,   z.Forward-looking windows can't have center=TruezAForward-looking windows don't support setting the closed argumentr>   r?   )r[   rE   rF   r   rG   )r   r%   r&   r'   r(   r)   rJ   rI   s   &&&&&&  r   r/   +FixedForwardWindowIndexer.get_window_bounds  s|    B MNNS  <D		!ZW=&&&''#q*-Czr   r   r2   rL   r   r   r   r|   r|     s    *X/ /r   r|   c                  P   a  ] tR tRtRtR^ R]R3R V 3R llltR	R R lltRtV ;t	# )
GroupbyIndexeri  zMCalculate bounds to compute groupby rolling, mimicking df.groupby().rolling()Nc               0    V ^8  d   QhRRRRRRRRR	RR
R/# )r   r   r   r   zint | BaseIndexergroupby_indiceszdict | Nonewindow_indexerztype[BaseIndexer]indexer_kwargsr   r   r   )r   s   "r   r   GroupbyIndexer.__annotate__  sF     "
 "
&"
 '"
 %	"

 *"
 $"
 
"
r   c           
        < T;'       g    / V n         W@n        V'       d   VP                  4       M/ V n        \        SV `  ! RRVRV P                  P                  RV4      /VB  R# )a  
Parameters
----------
index_array : np.ndarray or None
    np.ndarray of the index of the original object that we are performing
    a chained groupby operation over. This index has been pre-sorted relative to
    the groups
window_size : int or BaseIndexer
    window size during the windowing operation
groupby_indices : dict or None
    dict of {group label: [positional index of rows belonging to the group]}
window_indexer : BaseIndexer
    BaseIndexer class determining the start and end bounds of each group
indexer_kwargs : dict or None
    Custom kwargs to be passed to window_indexer
**kwargs :
    keyword arguments that will be available when get_window_bounds is called
r   r   Nr   )r   r   copyr   rY   r!   pop)r   r   r   r   r   r   r   r\   s   &&&&&&,r   r!   GroupbyIndexer.__init__  sj    6  /44",7En1132 	
#	
++//{K	
 	
r   c               0    V ^8  d   QhRRRRRRRRR	RR
R/# r$   r   )r   s   "r   r   r   9  sN     K KK  K 	K
 K K 
'Kr   c                   . p. p^ pV P                   P                  4        EF  p	V P                  e&   V P                  P                  \	        V	4      4      p
MV P                  p
V P
                  ! RRV
RV P                  /V P                  B pVP                  \        V	4      W#WE4      w  rVP                  \        P                  4      pVP                  \        P                  4      p\        V4      \        V4      8X  g   Q R4       h\        P                  ! W\        V	4      ,           4      pV\        V	4      ,          p\        P                  ! WR,          ^,           .4      P                  \        P                  RR7      pVP                  VP                  \	        V4      4      4       VP                  VP                  \	        V4      4      4       EK  	  \        V4      ^ 8X  dM   \        P                  ! . \        P                  R7      \        P                  ! . \        P                  R7      3# \        P                   ! V4      p\        P                   ! V4      pW3# )	r,   r   r   z6these should be equal in length from get_window_boundsF)r   r?   r   ra   )r   valuesr   taker   r   r   r   r/   lenastyperE   r>   rF   appendarrayconcatenate)r   r%   r&   r'   r(   r)   start_arrays
end_arrayswindow_indices_startindicesr   indexerrJ   rI   window_indicess   &&&&&&         r   r/    GroupbyIndexer.get_window_bounds9  s   H 
 ++224G +"..334G4PQ"..)) ' ,, %%G
 !22Gk6JE LL*E**RXX&Cu:S) H)
  YY$S\&IN !CL0 YY~r8JQ8N7OPWWu X N  3 34G4N OPn112Ec2JKL? 5@ |!88Bbhh/"BHH1MMM|,nnZ(zr   )r   r   r   r2   )
r3   r4   r5   r6   r7   r   r!   r/   r8   rq   rr   s   @r   r   r     s.    W *.)*'+,7&*"
 "
HK Kr   r   c                  *    ] tR tRtRtRR R lltRtR# )ExponentialMovingWindowIndexeri  z/Calculate ewm window bounds (the entire window)Nc               0    V ^8  d   QhRRRRRRRRR	RR
R/# r$   r   )r   s   "r   r   +ExponentialMovingWindowIndexer.__annotate__  sN     !U !U!U  !U 	!U
 !U !U 
'!Ur   c                    \         P                  ! ^ .\         P                  R7      \         P                  ! V.\         P                  R7      3# rx   )rE   r   r>   r.   s   &&&&&&r   r/   0ExponentialMovingWindowIndexer.get_window_bounds  s2    B xx288,bhh
|288.TTTr   r   r2   rL   r   r   r   r   r     s    9!U !Ur   r   )r7   
__future__r   datetimer   numpyrE   pandas._libs.tslibsr   pandas._libs.window.indexersr   pandas.util._decoratorsr   pandas.core.dtypes.commonr   pandas.core.indexes.datetimesr   pandas.tseries.offsetsr	   r   r:   rN   rT   rt   r|   r   r   r   r   r   <module>r      s    R "   * I . 9 7 ' !"T" T" #T"n3 3l/
K /
d !"p+ p #pf'
{ '
T !"\ \ #\~r[ rj$U[ $Ur   