U
    ¿mœd8y  ã                   @  sü  d Z ddlmZ ddlmZmZ ddlmZmZm	Z	 ddl
ZddlmZmZmZ ddlmZmZmZmZmZ ddlmZ dd	lmZ dd
lmZmZmZmZ ddlm Z m!Z!m"Z" erÀddl#m$Z$ dddœdd„Z%dddœdd„Z&d‚dddœdd„Z'ddddgZ(d d!d"d#d$d%d&d'd(d)d*d+d,d-gZ)d.d/d.d0œd1d2„Z*d.dd3d4œd5d6„Z+dƒd9d.d:d;d3d.dd<ddd=d>œd?d@„Z,d„d9d/d:d.d3d.dd<d=dAœ	dBdC„Z-d/d.d9dDœdEdF„Z.d…d9d9dd3d.dd<dd3d=dGœ
dHdI„Z/d†ddJœdKdL„Z0d‡dMddNœdOdP„Z1dˆdMd:dQœdRdS„Z2d‰d:dUdVœdWdX„Z3d9d.d3dd=dYœdZd[„Z4dŠd9d.d\d3dd=d]œd^d_„Z5d‹d`ddaœdbdc„Z6dddddeœdfdg„Z7e7dŒd9d3d`dhdiœdjdk„ƒZ8e7d�d9d3d`dhdiœdldm„ƒZ9e7dŽd9d`dnœdodp„ƒZ:e7d�d`dqœdrds„ƒZ;e8e9dtœZ<d�ddvœdwdx„Z=ddyœdzd{„Z>dd|œd}d~„Z?ddddœd€d�„Z@dS )‘z$
Routines for filling missing data.
é    )Úannotations)ÚpartialÚwraps)ÚTYPE_CHECKINGÚAnyÚcastN)ÚNaTÚalgosÚlib)Ú	ArrayLikeÚAxisÚAxisIntÚFÚnpt)Úimport_optional_dependency)Úinfer_dtype_from)Úis_array_likeÚis_numeric_v_string_likeÚis_object_dtypeÚneeds_i8_conversion)Úis_valid_na_for_dtypeÚisnaÚna_value_for_dtype)ÚIndexznpt.NDArray[np.bool_]Úint)ÚmaskÚlengthc                 C  s8   t | ƒr4t| ƒ|kr,tdt| ƒ› d|› �ƒ‚| | } | S )zJ
    Validate the size of the values passed to ExtensionArray.fillna.
    z'Length of 'value' does not match. Got (z)  expected )r   ÚlenÚ
ValueError)Úvaluer   r   © r    úL/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/pandas/core/missing.pyÚcheck_value_size1   s    ÿr"   r   )ÚarrÚreturnc           
      C  sÖ   t |ƒ\}}tj||d�}d}t| ƒr4d}t| ƒ }t|ƒ}||  }tj| jtd�}|D ]b}t| |ƒrjqZ|r’tj| jtj	d�}	| | |k|	|< n"| |k}	t
|	tjƒs´|	jtdd�}	||	O }qZ| ¡ rÒ|t| ƒO }|S )a	  
    Return a masking array of same size/shape as arr
    with entries equaling any member of values_to_mask set to True

    Parameters
    ----------
    arr : ArrayLike
    values_to_mask: list, tuple, or scalar

    Returns
    -------
    np.ndarray[bool]
    )ÚdtypeFT)r%   Zna_value)r   ÚnpÚarrayr   r   ZzerosÚshapeÚboolr   Zbool_Ú
isinstanceÚndarrayZto_numpyÚany)
r#   Zvalues_to_maskr%   Zpotential_naZarr_maskZna_maskZnonnar   ÚxZnew_maskr    r    r!   Úmask_missing@   s,    



r.   Fz
str | Noner)   )ÚmethodÚallow_nearestc                 C  sv   | dkrd S t | tƒr8|  ¡ } | dkr,d} n| dkr8d} ddg}d}|rV| d¡ d}| |krrtd	|› d
| › �ƒ‚| S )N)NZasfreqZffillÚpadZbfillÚbackfillzpad (ffill) or backfill (bfill)Únearestz(pad (ffill), backfill (bfill) or nearestzInvalid fill method. Expecting z. Got )r*   ÚstrÚlowerÚappendr   )r/   r0   Zvalid_methodsZ	expectingr    r    r!   Úclean_fill_methody   s     

r7   ÚlinearÚtimeÚindexÚvaluesr3   ÚzeroÚslinearÚ	quadraticÚcubicÚbarycentricÚkroghÚsplineÚ
polynomialÚfrom_derivativesÚpiecewise_polynomialÚpchipÚakimaÚcubicspliner4   r   )r/   r:   r$   c                 K  sh   |  d¡}| dkr"|d kr"tdƒ‚tt }| |krHtd|› d| › d�ƒ‚| dkrd|jsdt| › d�ƒ‚| S )	NÚorder)rB   rC   z7You must specify the order of the spline or polynomial.zmethod must be one of z. Got 'z
' instead.)rA   rE   rF   z4 interpolation requires that the index be monotonic.)Úgetr   Ú
NP_METHODSÚ
SP_METHODSZis_monotonic_increasing)r/   r:   ÚkwargsrI   Úvalidr    r    r!   Úclean_interp_method§   s    
ÿrO   z
int | None)ÚhowÚis_validr$   c                C  s†   |dkst ‚t| ƒdkrdS | jdkr2|jdd�}|dkrL|dd…  ¡ }n&|dkrrt| ƒd |ddd	…  ¡  }|| }|s‚dS |S )
aG  
    Retrieves the index of the first valid value.

    Parameters
    ----------
    values : ndarray or ExtensionArray
    how : {'first', 'last'}
        Use this parameter to change between the first or last valid index.
    is_valid: np.ndarray
        Mask to find na_values.

    Returns
    -------
    int or None
    )ÚfirstÚlastr   Né   é   ©ÚaxisrR   rS   éÿÿÿÿ)ÚAssertionErrorr   Úndimr,   Zargmax)r;   rP   rQ   ZidxposZ	chk_notnar    r    r!   Úfind_valid_indexº   s    
r[   r1   Úforwardú
np.ndarrayr   zIndex | Nonez
Any | NoneÚNone)Údatar/   rW   r:   ÚlimitÚlimit_directionÚ
limit_areaÚ
fill_valueÚcoerceÚdowncastr$   c
                 K  s‚   zt |ƒ}W n tk
r$   d}Y nX |dk	rR|dk	r>tdƒ‚t| ||||d� n,|dk	s^t‚tf | |||||||dœ|
—Ž dS )z…
    Wrapper to dispatch to either interpolate_2d or _interpolate_2d_with_fill.

    Notes
    -----
    Alters 'data' in-place.
    Nz&Cannot pass both fill_value and method)r/   rW   r`   rb   )r_   r:   rW   r/   r`   ra   rb   rc   )r7   r   Úinterpolate_2drY   Ú_interpolate_2d_with_fill)r_   r/   rW   r:   r`   ra   rb   rc   rd   re   rM   Úmr    r    r!   Úinterpolate_array_2dã   s6    
ûø	÷ri   )	r_   r:   rW   r/   r`   ra   rb   rc   r$   c                   sö   t ˆ|fˆŽ tˆ | jƒr(t| jdd�‰ ˆdkrFt|jƒsBtdƒ‚d‰dddg}	ˆ ¡ ‰ˆ|	krvtd	|	› d
ˆ› d�ƒ‚ˆdk	r¬ddg}
ˆ ¡ ‰ˆ|
kr¬td|
› dˆ› d�ƒ‚tjdˆd�‰t	|ˆƒ‰dddœ‡ ‡‡‡‡‡‡fdd„}t
 ||| ¡ dS )zÝ
    Column-wise application of _interpolate_1d.

    Notes
    -----
    Alters 'data' in-place.

    The signature does differ from _interpolate_1d because it only
    includes what is needed for Block.interpolate.
    F)Úcompatr9   zStime-weighted interpolation only works on Series or DataFrames with a DatetimeIndexr;   r\   ÚbackwardZbothz*Invalid limit_direction: expecting one of z, got 'z'.NÚinsideÚoutsidez%Invalid limit_area: expecting one of z, got Ú.)Znobsr`   r]   r^   )Úyvaluesr$   c                   s$   t f ˆ| ˆˆˆˆˆ ddœˆ—Ž d S )NF)Úindicesro   r/   r`   ra   rb   rc   Úbounds_error)Ú_interpolate_1d)ro   ©rc   rp   rM   r`   rb   ra   r/   r    r!   ÚfuncR  s    ø	÷z'_interpolate_2d_with_fill.<locals>.func)rO   r   r%   r   r   r   r5   r	   Zvalidate_limitÚ_index_to_interp_indicesr&   Úapply_along_axis)r_   r:   rW   r/   r`   ra   rb   rc   rM   Zvalid_limit_directionsZvalid_limit_areasrt   r    rs   r!   rg     s4    
ÿ
ÿÿ
 rg   )r:   r/   r$   c                 C  s`   | j }t|jƒr| d¡}|dkr4|}ttj|ƒ}n(t |¡}|dkr\|jtjkr\t	 
|¡}|S )zE
    Convert Index to ndarray of indices to pass to NumPy/SciPy.
    Úi8r8   )r;   r:   )Ú_valuesr   r%   Úviewr   r&   r+   ÚasarrayZobject_r
   Zmaybe_convert_objects)r:   r/   ZxarrZindsr    r    r!   ru   j  s    



ru   )
rp   ro   r/   r`   ra   rb   rc   rq   rI   r$   c	                 K  s¾  t |ƒ}
|
 }| ¡ sdS | ¡ r&dS tt |
¡ƒ}t|d|d�}|dkrNd}tt|ƒƒ}t|d|d�}|dkrxt|ƒ}ttd| t|ƒƒƒ}|dkr¬|tt	|
|dƒƒB }n.|dkrÊ|tt	|
d|ƒƒB }ntt	|
||ƒƒ}|d	krð|||B O }n|d
k�r|| | }||O }t
|ƒ}t|jƒ}|�r0| d¡}|tk�rpt | | ¡}t | |
 | | | || | ¡||
< n.t| | || | |
 f||||dœ|	—Ž||
< |�r°tj||< n
tj||< dS )a  
    Logic for the 1-d interpolation.  The input
    indices and yvalues will each be 1-d arrays of the same length.

    Bounds_error is currently hardcoded to False since non-scipy ones don't
    take it as an argument.

    Notes
    -----
    Fills 'yvalues' in-place.
    NrR   ©rP   rQ   r   rS   rU   r\   rk   rl   rm   rw   )r/   rc   rq   rI   )r   r,   ÚallÚsetr&   Zflatnonzeror[   Úranger   Ú_interp_limitÚsortedr   r%   ry   rK   ZargsortZinterpÚ_interpolate_scipy_wrapperr   r   Únan)rp   ro   r/   r`   ra   rb   rc   rq   rI   rM   ÚinvalidrN   Zall_nansZfirst_valid_indexZ
start_nansZlast_valid_indexZend_nansZpreserve_nansZmid_nansZis_datetimelikeZindexerr    r    r!   rr   €  sh    



 
 
ÿ
ýùø

rr   )rq   c                 K  sx  |› d�}t d|d� ddlm}	 t |¡}|	j|	jttdœ}
t| ddƒrb| j	 
d	¡| 
d	¡ } }|d
krv|	j|
d
< n"|dkrˆt|
d< n|dkr˜t|
d< ddddddg}||krÚ|dkr¼|}|	j| ||||d�}||ƒ}nš|dk�r&t|ƒsö|dk�rtd|› �ƒ‚|	j| |fd|i|—Ž}||ƒ}nN| jj�s8|  ¡ } |jj�sJ| ¡ }|jj�s\| ¡ }|
| }|| ||f|Ž}|S )zµ
    Passed off to scipy.interpolate.interp1d. method is scipy's kind.
    Returns an array interpolated at new_x.  Add any new methods to
    the list in _clean_interp_method.
    z interpolation requires SciPy.Úscipy)Úextrar   ©Úinterpolate)r@   rA   rD   rE   Z_is_all_datesFrw   rF   rG   rH   r3   r<   r=   r>   r?   rC   )Úkindrc   rq   rB   z;order needs to be specified and greater than 0; got order: Úk)r   r„   r‡   r&   rz   Zbarycentric_interpolateZkrogh_interpolateÚ_from_derivativesÚgetattrrx   ZastypeZpchip_interpolateÚ_akima_interpolateÚ_cubicspline_interpolateZinterp1dr   r   ZUnivariateSplineÚflagsZ	writeableÚcopy)r-   ÚyZnew_xr/   rc   rq   rI   rM   r…   r‡   Zalt_methodsZinterp1d_methodsZterpZnew_yr    r    r!   r�   ì  sf    

ü
ú    ÿ

ÿ



r�   zint | list[int] | None)ÚderÚextrapolatec           	      C  s4   ddl m} |jj}|| | dd¡||d�}||ƒS )aŸ  
    Convenience function for interpolate.BPoly.from_derivatives.

    Construct a piecewise polynomial in the Bernstein basis, compatible
    with the specified values and derivatives at breakpoints.

    Parameters
    ----------
    xi : array-like
        sorted 1D array of x-coordinates
    yi : array-like or list of array-likes
        yi[i][j] is the j-th derivative known at xi[i]
    order: None or int or array-like of ints. Default: None.
        Specifies the degree of local polynomials. If not None, some
        derivatives are ignored.
    der : int or list
        How many derivatives to extract; None for all potentially nonzero
        derivatives (that is a number equal to the number of points), or a
        list of derivatives to extract. This number includes the function
        value as 0th derivative.
     extrapolate : bool, optional
        Whether to extrapolate to ouf-of-bounds points based on first and last
        intervals, or to return NaNs. Default: True.

    See Also
    --------
    scipy.interpolate.BPoly.from_derivatives

    Returns
    -------
    y : scalar or array-like
        The result, of length R or length M or M by R.
    r   r†   rX   rU   )Zordersr’   )r„   r‡   ZBPolyrD   Úreshape)	ÚxiÚyir-   rI   r‘   r’   r‡   r/   rh   r    r    r!   rŠ   9  s    $rŠ   )r‘   rW   c                 C  s(   ddl m} |j| ||d�}|||d�S )a[  
    Convenience function for akima interpolation.
    xi and yi are arrays of values used to approximate some function f,
    with ``yi = f(xi)``.

    See `Akima1DInterpolator` for details.

    Parameters
    ----------
    xi : array-like
        A sorted list of x-coordinates, of length N.
    yi : array-like
        A 1-D array of real values.  `yi`'s length along the interpolation
        axis must be equal to the length of `xi`. If N-D array, use axis
        parameter to select correct axis.
    x : scalar or array-like
        Of length M.
    der : int, optional
        How many derivatives to extract; None for all potentially
        nonzero derivatives (that is a number equal to the number
        of points), or a list of derivatives to extract. This number
        includes the function value as 0th derivative.
    axis : int, optional
        Axis in the yi array corresponding to the x-coordinate values.

    See Also
    --------
    scipy.interpolate.Akima1DInterpolator

    Returns
    -------
    y : scalar or array-like
        The result, of length R or length M or M by R,

    r   r†   rV   )Únu)r„   r‡   ZAkima1DInterpolator)r”   r•   r-   r‘   rW   r‡   ÚPr    r    r!   rŒ   f  s    $rŒ   ú
not-a-knotzstr | tuple[Any, Any])rW   Úbc_typec                 C  s(   ddl m} |j| ||||d�}||ƒS )aq  
    Convenience function for cubic spline data interpolator.

    See `scipy.interpolate.CubicSpline` for details.

    Parameters
    ----------
    xi : array-like, shape (n,)
        1-d array containing values of the independent variable.
        Values must be real, finite and in strictly increasing order.
    yi : array-like
        Array containing values of the dependent variable. It can have
        arbitrary number of dimensions, but the length along ``axis``
        (see below) must match the length of ``x``. Values must be finite.
    x : scalar or array-like, shape (m,)
    axis : int, optional
        Axis along which `y` is assumed to be varying. Meaning that for
        ``x[i]`` the corresponding values are ``np.take(y, i, axis=axis)``.
        Default is 0.
    bc_type : string or 2-tuple, optional
        Boundary condition type. Two additional equations, given by the
        boundary conditions, are required to determine all coefficients of
        polynomials on each segment [2]_.
        If `bc_type` is a string, then the specified condition will be applied
        at both ends of a spline. Available conditions are:
        * 'not-a-knot' (default): The first and second segment at a curve end
          are the same polynomial. It is a good default when there is no
          information on boundary conditions.
        * 'periodic': The interpolated functions is assumed to be periodic
          of period ``x[-1] - x[0]``. The first and last value of `y` must be
          identical: ``y[0] == y[-1]``. This boundary condition will result in
          ``y'[0] == y'[-1]`` and ``y''[0] == y''[-1]``.
        * 'clamped': The first derivative at curves ends are zero. Assuming
          a 1D `y`, ``bc_type=((1, 0.0), (1, 0.0))`` is the same condition.
        * 'natural': The second derivative at curve ends are zero. Assuming
          a 1D `y`, ``bc_type=((2, 0.0), (2, 0.0))`` is the same condition.
        If `bc_type` is a 2-tuple, the first and the second value will be
        applied at the curve start and end respectively. The tuple values can
        be one of the previously mentioned strings (except 'periodic') or a
        tuple `(order, deriv_values)` allowing to specify arbitrary
        derivatives at curve ends:
        * `order`: the derivative order, 1 or 2.
        * `deriv_value`: array-like containing derivative values, shape must
          be the same as `y`, excluding ``axis`` dimension. For example, if
          `y` is 1D, then `deriv_value` must be a scalar. If `y` is 3D with
          the shape (n0, n1, n2) and axis=2, then `deriv_value` must be 2D
          and have the shape (n0, n1).
    extrapolate : {bool, 'periodic', None}, optional
        If bool, determines whether to extrapolate to out-of-bounds points
        based on first and last intervals, or to return NaNs. If 'periodic',
        periodic extrapolation is used. If None (default), ``extrapolate`` is
        set to 'periodic' for ``bc_type='periodic'`` and to True otherwise.

    See Also
    --------
    scipy.interpolate.CubicHermiteSpline

    Returns
    -------
    y : scalar or array-like
        The result, of shape (m,)

    References
    ----------
    .. [1] `Cubic Spline Interpolation
            <https://en.wikiversity.org/wiki/Cubic_Spline_Interpolation>`_
            on Wikiversity.
    .. [2] Carl de Boor, "A Practical Guide to Splines", Springer-Verlag, 1978.
    r   r†   )rW   r™   r’   )r„   r‡   ZCubicSpline)r”   r•   r-   rW   r™   r’   r‡   r—   r    r    r!   r�   ‘  s    M    ÿr�   )r;   r/   r`   rb   r$   c                 C  s¨   t | ƒ}| }| ¡ s¤t| d|d�}|dkr0d}t| d|d�}|dkrNt| ƒ}t| ||d� |dkrvd|||d	 …< n$|d
kršd |d|…< ||d	 d…< tj| |< dS )a¶  
    Apply interpolation and limit_area logic to values along a to-be-specified axis.

    Parameters
    ----------
    values: np.ndarray
        Input array.
    method: str
        Interpolation method. Could be "bfill" or "pad"
    limit: int, optional
        Index limit on interpolation.
    limit_area: str
        Limit area for interpolation. Can be "inside" or "outside"

    Notes
    -----
    Modifies values in-place.
    rR   r{   Nr   rS   )r/   r`   rl   FrU   rm   )r   r|   r[   r   rf   r&   r‚   )r;   r/   r`   rb   rƒ   rQ   rR   rS   r    r    r!   Ú_interpolate_with_limit_areaç  s&    ýrš   r   )r;   r/   rW   r`   rb   r$   c                 C  s¢   |dk	r&t  tt|||d�|| ¡ dS |dkr6dd„ ndd„ }| jdkrl|dkrXtdƒ‚|  td	| j ƒ¡} t	|ƒ}|| ƒ}|d
kr’t
||d� nt||d� dS )a  
    Perform an actual interpolation of values, values will be make 2-d if
    needed fills inplace, returns the result.

    Parameters
    ----------
    values: np.ndarray
        Input array.
    method: str, default "pad"
        Interpolation method. Could be "bfill" or "pad"
    axis: 0 or 1
        Interpolation axis
    limit: int, optional
        Index limit on interpolation.
    limit_area: str, optional
        Limit area for interpolation. Can be "inside" or "outside"

    Notes
    -----
    Modifies values in-place.
    N)r/   r`   rb   r   c                 S  s   | S ©Nr    ©r-   r    r    r!   Ú<lambda>I  ó    z interpolate_2d.<locals>.<lambda>c                 S  s   | j S r›   )ÚTrœ   r    r    r!   r�   I  rž   rU   z0cannot interpolate on a ndim == 1 with axis != 0)rU   r1   ©r`   )r&   rv   r   rš   rZ   rY   r“   Útupler(   r7   Ú_pad_2dÚ_backfill_2d)r;   r/   rW   r`   rb   ZtransfZtvaluesr    r    r!   rf     s.    	üî
rf   znpt.NDArray[np.bool_] | None)r   r$   c                 C  s    |d krt | ƒ}| tj¡}|S r›   )r   ry   r&   Zuint8©r;   r   r    r    r!   Ú_fillna_prep]  s    r¥   r   )rt   r$   c                   s    t ˆ ƒd‡ fdd„	ƒ}tt|ƒS )z>
    Wrapper to handle datetime64 and timedelta64 dtypes.
    Nc                   sP   t | jƒrB|d krt| ƒ}ˆ |  d¡||d�\}}| | j¡|fS ˆ | ||d�S )Nrw   )r`   r   )r   r%   r   ry   )r;   r`   r   Úresult©rt   r    r!   Únew_funcn  s    
z&_datetimelike_compat.<locals>.new_func)NN)r   r   r   )rt   r¨   r    r§   r!   Ú_datetimelike_compati  s    r©   z(tuple[np.ndarray, npt.NDArray[np.bool_]])r;   r`   r   r$   c                 C  s"   t | |ƒ}tj| ||d� | |fS ©Nr    )r¥   r	   Zpad_inplace©r;   r`   r   r    r    r!   Ú_pad_1d}  s    
r¬   c                 C  s"   t | |ƒ}tj| ||d� | |fS rª   )r¥   r	   Zbackfill_inplacer«   r    r    r!   Ú_backfill_1dˆ  s    
r­   r¤   c                 C  s0   t | |ƒ}t | j¡r(tj| ||d� n | |fS rª   )r¥   r&   r|   r(   r	   Zpad_2d_inplacer«   r    r    r!   r¢   “  s    
r¢   )r   c                 C  s0   t | |ƒ}t | j¡r(tj| ||d� n | |fS rª   )r¥   r&   r|   r(   r	   Zbackfill_2d_inplacer«   r    r    r!   r£   Ÿ  s    
r£   ©r1   r2   rU   )rZ   c                 C  s&   t | ƒ} |dkrt|  S ttdœ|  S )NrU   r®   )r7   Ú_fill_methodsr¢   r£   )r/   rZ   r    r    r!   Úget_fill_func®  s    r°   )r$   c                 C  s   t | dd�S )NT)r0   )r7   )r/   r    r    r!   Úclean_reindex_fill_methodµ  s    r±   )rƒ   c                   s¤   t | ƒ‰ tƒ }tƒ }‡ fdd„}|dk	rN|dkrDtt | ¡d ƒ}n
|| |ƒ}|dk	rœ|dkrb|S t|| ddd… |ƒƒ}tˆ d t |¡ ƒ}|dkrœ|S ||@ S )ak  
    Get indexers of values that won't be filled
    because they exceed the limits.

    Parameters
    ----------
    invalid : np.ndarray[bool]
    fw_limit : int or None
        forward limit to index
    bw_limit : int or None
        backward limit to index

    Returns
    -------
    set of indexers

    Notes
    -----
    This is equivalent to the more readable, but slower

    .. code-block:: python

        def _interp_limit(invalid, fw_limit, bw_limit):
            for x in np.where(invalid)[0]:
                if invalid[max(0, x - fw_limit):x + bw_limit + 1].all():
                    yield x
    c                   s`   t |ˆ ƒ}t| |d ƒ d¡}tt |¡d | ƒtt | d |d …   ¡ dk¡d ƒB }|S )NrU   r   )ÚminÚ_rolling_windowr|   r}   r&   ÚwhereZcumsum)rƒ   r`   ZwindowedÚidx©ÚNr    r!   ÚinnerÜ  s    
"ÿz_interp_limit.<locals>.innerNr   rX   rU   )r   r}   r&   r´   Úlistrz   )rƒ   Zfw_limitZbw_limitZf_idxZb_idxr¸   Z	b_idx_invr    r¶   r!   r   ¹  s     
r   )ÚaÚwindowr$   c                 C  sJ   | j dd… | j d | d |f }| j| jd f }tjjj| ||d�S )z™
    [True, True, False, True, False], 2 ->

    [
        [True,  True],
        [True, False],
        [False, True],
        [True, False],
    ]
    NrX   rU   )r(   Ústrides)r(   r¼   r&   r
   Zstride_tricksZ
as_strided)rº   r»   r(   r¼   r    r    r!   r³   ø  s    $r³   )F)	r1   r   NNr\   NNFN)r8   Nr\   NN)r8   Nr\   NNFN)NFN)Nr   F)r   r   )r   r˜   N)r1   r   NN)N)NN)NN)NN)NN)rU   )AÚ__doc__Ú
__future__r   Ú	functoolsr   r   Útypingr   r   r   Únumpyr&   Zpandas._libsr   r	   r
   Zpandas._typingr   r   r   r   r   Zpandas.compat._optionalr   Zpandas.core.dtypes.castr   Zpandas.core.dtypes.commonr   r   r   r   Zpandas.core.dtypes.missingr   r   r   Zpandasr   r"   r.   r7   rK   rL   rO   r[   ri   rg   ru   rr   r�   rŠ   rŒ   r�   rš   rf   r¥   r©   r¬   r­   r¢   r£   r¯   r°   r±   r   r³   r    r    r    r!   Ú<module>   sÂ   9ò+         ö$9     ø R       ÷"q   ùN     ÿ-/   úV1    ûH ÿ  ý
  ý

?