
     j                    n    d dl mZ d dlmZ d dlZd dlmZmZ er
d dl	m
Z
mZmZ ddZddZddZddZdS )    )annotations)TYPE_CHECKINGN)isnana_value_for_dtype)	ArrayLikeScalarnptvaluesr   qsnpt.NDArray[np.float64]interpolationstrreturnc                    t          | t          j                  r8t          | j        d          }t          |           }t          | ||||          S |                     ||          S )a  
    Compute the quantiles of the given values for each quantile in `qs`.

    Parameters
    ----------
    values : np.ndarray or ExtensionArray
    qs : np.ndarray[float64]
    interpolation : str

    Returns
    -------
    np.ndarray or ExtensionArray
    F)compat)
isinstancenpndarrayr   dtyper   quantile_with_mask	_quantile)r
   r   r   
fill_valuemasks        tC:\Users\Terasoftware\OneDrive\Desktop\faahhh\fyndo\fyndo\venv\Lib\site-packages\pandas/core/array_algos/quantile.pyquantile_compatr      sc      &"*%% 3'UCCC
F||!&$
BNNNM222    
np.ndarrayr   npt.NDArray[np.bool_]c                V   | j         |j         k    sJ | j        dk    rCt          j        |           } t          j        |          }t	          | ||||          }|d         S | j        dk    sJ | j         d         dk    }|rvt          j        |gt          |          z            }t          j        |t          |                                         t          |           t          |                    }n2t          | |dz  |||          }t          j
        |          }|j        }|S )a  
    Compute the quantiles of the given values for each quantile in `qs`.

    Parameters
    ----------
    values : np.ndarray
        For ExtensionArray, this is _values_for_factorize()[0]
    mask : np.ndarray[bool]
        mask = isna(values)
        For ExtensionArray, this is computed before calling _value_for_factorize
    fill_value : Scalar
        The value to interpret fill NA entries with
        For ExtensionArray, this is _values_for_factorize()[1]
    qs : np.ndarray[float64]
    interpolation : str
        Type of interpolation

    Returns
    -------
    np.ndarray

    Notes
    -----
    Assumes values is already 2D.  For ExtensionArray this means np.atleast_2d
    has been called on _values_for_factorize()[0]

    Quantile is computed along axis=1.
       r      g      Y@)na_valuer   r   )shapendimr   
atleast_2dr   arraylenrepeatreshape_nanpercentileasarrayT)	r
   r   r   r   r   
res_valuesis_emptyflatresults	            r   r   r   ,   s(   F <4:%%%%{a v&&}T""'j"mTT
!};!|A!#H  xs2ww.//4V--55c&kk3r77KKJ'
 
 
 F##Mr   r"   r   Scalar | np.ndarrayc                    | |          } t          |           dk    r"t          j        t          |          |          S t          j        | ||          S )a  
    Wrapper for np.percentile that skips missing values, specialized to
    1-dimensional case.

    Parameters
    ----------
    values : array over which to find quantiles
    mask : ndarray[bool]
        locations in values that should be considered missing
    qs : np.ndarray[float64] of quantile indices to find
    na_value : scalar
        value to return for empty or all-null values
    interpolation : str

    Returns
    -------
    quantiles : scalar or array
    r   )method)r'   r   full
percentile)r
   r   r   r"   r   s        r   _nanpercentile_1dr6   o   s`    4 TE]F
6{{a * ws2ww)))=
    r   c               6   | j         j        dv rTt          |                     d                              d          |          }|                    | j                   S |                                r|j        | j        k    sJ fdt          t          |           t          |                    D             }| j         j        dk    r!t          j
        || j                   j        }nt          j
        |          j        }|j         | j         k    rb|                                sN||                    | j         d          k                                    r|                    | j         d          }|S t          j        | d	
          S )a  
    Wrapper for np.percentile that skips missing values.

    Parameters
    ----------
    values : np.ndarray[ndim=2]  over which to find quantiles
    qs : np.ndarray[float64] of quantile indices to find
    na_value : scalar
        value to return for empty or all-null values
    mask : np.ndarray[bool]
        locations in values that should be considered missing
    interpolation : str

    Returns
    -------
    quantiles : scalar or array
    mMi8)r   r"   r   r   c           	     >    g | ]\  }}t          ||           S ))r   )r6   ).0valmr   r"   r   s      r   
<listcomp>z"_nanpercentile.<locals>.<listcomp>   s@     
 
 
a c1b(-PPP
 
 
r   f)r   F)copyr    )axisr3   )r   kindr*   viewastypeanyr#   ziplistr   r+   r,   allr5   )r
   r   r"   r   r   r0   s    `` ` r   r*   r*      s   4 |D  +KK]]4(('
 
 
 }}V\***xxzz 
zV\))))
 
 
 
 
 
Vd4jj99
 
 
 <# 	AZfl;;;=FFZ'')F,A

A v}}V\}FFFKKMMA  v|%@@} !
 
 
 	
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   r1   )r
   r   r   r   r   r   r   r   )
__future__r   typingr   numpyr   pandas.core.dtypes.missingr   r   pandas._typingr   r   r	   r   r   r6   r*    r   r   <module>rO      s    " " " " " "                       
           3 3 3 30@ @ @ @F) ) ) )XG
 G
 G
 G
 G
 G
r   