
    ih                       d Z ddlmZ ddlZddlZddlZddlZddl	m
Z
mZmZmZmZ ddlmZmZmZmZmZ ej*                  rddlmZ ddlmZmZmZ d	Z ej:                  d
      Z ej:                  d      Z ej:                  d      Z  e!d      Z"ejF                  dd       Z$ejF                  dd       Z$d Z$ejF                  dd       Z%ejF                  dd       Z%d Z%ejF                  	 	 	 	 	 	 dd       Z&ejF                  	 	 	 	 	 	 dd       Z&ejF                  	 	 	 	 	 	 dd       Z&ejF                  	 	 	 	 	 	 dd       Z&ejF                  	 	 	 	 	 	 dd       Z&ejF                  dd       Z&ejF                  ddd       Z&ejF                  ddd       Z&ddZ&ejF                  dd       Z'ejF                  dd       Z'd Z'ejF                  	 	 	 	 	 	 dd        Z(ejF                  	 	 	 	 	 	 dd!       Z(ejF                  	 	 	 	 	 	 dd"       Z(ejF                  	 	 	 	 	 	 dd#       Z(ejF                  	 	 	 	 	 	 dd$       Z(ejF                  	 	 	 	 	 	 dd%       Z(ejF                  	 d	 	 	 	 	 dd&       Z(ejF                  ddd'       Z(dd(Z(ddd)Z) ej:                  d*e*e!d+      Z+ ej:                  d,e*e!d+      Z, ej:                  d-e*e!d+      Z-ddd.Z.dd/Z/ddd0Z0ejF                  e
f	 	 	 	 	 dd1       Z1ejF                  	 	 	 	 	 	 dd2       Z1ejF                  e
f	 	 	 	 	 dd3       Z1ejF                  	 	 	 	 	 	 dd4       Z1e
fd5Z1ejF                  de
f	 	 	 	 	 	 	 dd6       Z2ejF                  e
f	 	 	 	 	 	 	 dd7       Z2ejF                  	 	 	 	 	 	 	 	 dd8       Z2ejF                  	 d	 	 	 	 	 	 	 dd9       Z2ejF                  de
f	 	 	 	 	 	 	 dd:       Z2ejF                  e
f	 	 	 	 	 	 	 dd;       Z2ejF                  	 	 	 	 	 	 	 	 dd<       Z2ejF                  	 d	 	 	 	 	 	 	 dd=       Z2ejF                  e
fdd>       Z2ejF                  dd?       Z2de
fd@Z2ejF                  	 	 	 	 	 	 ddA       Z3ejF                  	 	 	 	 	 	 ddB       Z3ejF                  	 	 	 	 	 	 ddC       Z3ejF                  	 	 	 	 	 	 ddD       Z3ejF                  	 	 	 	 	 	 ddE       Z3ejF                  	 	 	 	 	 	 ddF       Z3ejF                  dddG       Z3ddHZ3ejF                  e
f	 	 	 	 	 ddI       Z4ejF                  	 	 	 	 	 	 ddJ       Z4ejF                  e
f	 	 	 	 	 ddK       Z4ejF                  	 	 	 	 	 	 ddL       Z4e
fdMZ4ejF                  de
f	 	 	 	 	 	 	 ddN       Z5ejF                  e
f	 	 	 	 	 	 	 ddO       Z5ejF                  	 	 	 	 	 	 	 	 ddP       Z5ejF                  	 d	 	 	 	 	 	 	 ddQ       Z5ejF                  de
f	 	 	 	 	 	 	 ddR       Z5ejF                  e
f	 	 	 	 	 	 	 ddS       Z5ejF                  	 	 	 	 	 	 	 	 ddT       Z5ejF                  	 d	 	 	 	 	 	 	 ddU       Z5ejF                  e
fddV       Z5ejF                  ddW       Z5de
fdXZ5ddYZ6ejF                  ddZ       Z7ejF                  dd[       Z7ejF                  dd\       Z7ejF                  dd]       Z7ejF                  dd^       Z7d_ Z7ejF                  dd`       Z8ejF                  dda       Z8ejF                  ddb       Z8ejF                  ddc       Z8dd Z8ejF                  ddde       Z9ejF                  dddf       Z9ddgZ9ejF                  ddh       Z:ejF                  ddi       Z:ejF                  dddj       Z:dddkZ:ejF                  	 	 	 	 	 	 ddl       Z;ejF                  	 	 	 	 	 	 ddm       Z;dn Z;ddoZ<ejF                  ddp       Z=ejF                  ddq       Z=dr Z=ddsZ>ejF                  ddt       Z?ejF                  ddu       Z?dv Z?ejF                  	 	 	 	 	 	 ddw       Z@ejF                  	 	 	 	 	 	 ddx       Z@ejF                  	 	 	 	 	 	 ddy       Z@ejF                  	 	 	 	 	 	 ddz       Z@ejF                  dd{       Z@ejF                  dd|       Z@ejF                  ddd}       Z@dd~Z@d ZAd ZBy)zD
Numerical/mathematical related functions.

.. versionadded:: 2.1.0
    )annotationsN   )UNSETUnsetiteratoriterator_with_defaultiteriteratee)IterateeObjTNumberNoDecimalTNumberTSupportsMulSupportsRound)Decimal)SupportsAddSupportsRichComparisonTSupportsSub)addceilclampdividefloormax_max_bymeanmean_bymedianmin_min_bymoving_meanmultiplypowerround_scaleslopestd_deviationsum_sum_bysubtract	transposevariancezscoreTT2T3infc                     y N abs     H/home/Script/Script_env/lib/python3.12/site-packages/pydash/numerical.pyr   r   =       .1    c                     y r1   r2   r3   s     r6   r   r   A   r7   r8   c                    | |z   S )a  
    Adds two numbers.

    Args:
        a: First number to add.
        b: Second number to add.

    Returns:
        number

    Example:

        >>> add(10, 5)
        15

    .. versionadded:: 2.1.0

    .. versionchanged:: 3.3.0
        Support adding two numbers when passed as positional arguments.

    .. versionchanged:: 4.0.0
        Only support two argument addition.
    r2   r3   s     r6   r   r   E   s    0 q5Lr8   c                     y r1   r2   
collections    r6   r&   r&   `       DGr8   c                     y r1   r2   r<   s    r6   r&   r&   d   s    >Ar8   c                    t        |       S )a  
    Sum each element in `collection`.

    Args:
        collection: Collection to process or first number to add.

    Returns:
        Result of summation.

    Example:

        >>> sum_([1, 2, 3, 4])
        10

    .. versionadded:: 2.1.0

    .. versionchanged:: 3.3.0
        Support adding two numbers when passed as positional arguments.

    .. versionchanged:: 4.0.0
        Move iteratee support to :func:`sum_by`. Move two argument addition to
        :func:`add`.
    )r'   r<   s    r6   r&   r&   h   s    0 *r8   c                     y r1   r2   r=   iteratees     r6   r'   r'      s     
r8   c                     y r1   r2   rB   s     r6   r'   r'           
r8   c                     y r1   r2   rB   s     r6   r'   r'      rE   r8   c                     y r1   r2   rB   s     r6   r'   r'      rE   r8   c                     y r1   r2   rB   s     r6   r'   r'      rE   r8   c                     y r1   r2   rB   s     r6   r'   r'          `cr8   c                     y r1   r2   rB   s     r6   r'   r'      s    ]`r8   c                     y r1   r2   rB   s     r6   r'   r'      s    WZr8   c                :    t        d t        | |      D              S )a  
    Sum each element in `collection`. If iteratee is passed, each element of `collection` is passed
    through an iteratee before the summation is computed.

    Args:
        collection: Collection to process or first number to add.
        iteratee: Iteratee applied per iteration or second number to add.

    Returns:
        Result of summation.

    Example:

        >>> sum_by([1, 2, 3, 4], lambda x: x**2)
        30

    .. versionadded:: 4.0.0
    c              3  &   K   | ]	  }|d      ywr   Nr2   ).0results     r6   	<genexpr>zsum_by.<locals>.<genexpr>   s     JVvayJ   )sumr	   rB   s     r6   r'   r'      s    & J|J'IJJJr8   c                     y r1   r2   r<   s    r6   r   r      s    LOr8   c                     y r1   r2   r<   s    r6   r   r      s    FIr8   c                    t        |       S )a  
    Calculate arithmetic mean of each element in `collection`.

    Args:
        collection: Collection to process.

    Returns:
        Result of mean.

    Example:

        >>> mean([1, 2, 3, 4])
        2.5

    .. versionadded:: 2.1.0

    .. versionchanged:: 4.0.0

        - Removed ``average`` and ``avg`` aliases.
        - Moved iteratee functionality to :func:`mean_by`.
    )r   r<   s    r6   r   r      s    , :r8   c                     y r1   r2   rB   s     r6   r   r           r8   c                     y r1   r2   rB   s     r6   r   r           r8   c                     y r1   r2   rB   s     r6   r   r      r[   r8   c                     y r1   r2   rB   s     r6   r   r      r[   r8   c                     y r1   r2   rB   s     r6   r   r      r[   r8   c                     y r1   r2   rB   s     r6   r   r     r[   r8   c                     y r1   r2   rB   s     r6   r   r   
  r[   r8   c                     y r1   r2   rB   s     r6   r   r     rJ   r8   c                2    t        | |      t        |       z  S )a  
    Calculate arithmetic mean of each element in `collection`. If iteratee is passed, each element
    of `collection` is passed through an iteratee before the mean is computed.

    Args:
        collection: Collection to process.
        iteratee: Iteratee applied per iteration.

    Returns:
        Result of mean.

    Example:

        >>> mean_by([1, 2, 3, 4], lambda x: x**2)
        7.5

    .. versionadded:: 4.0.0
    )r'   lenrB   s     r6   r   r     s    & *h'#j/99r8   c                8    t        t        j                  | |      S )ak  
    Round number up to precision.

    Args:
        x: Number to round up.
        precision: Rounding precision. Defaults to ``0``.

    Returns:
        Number rounded up.

    Example:

        >>> ceil(3.275) == 4.0
        True
        >>> ceil(3.215, 1) == 3.3
        True
        >>> ceil(6.004, 2) == 6.01
        True

    .. versionadded:: 3.3.0
    )roundermathr   x	precisions     r6   r   r   *  s    , 499a++r8   NumTr   NumT2NumT3c                2    ||}| }| |k  r|} | S | |kD  r|} | S )a  
    Clamps number within the inclusive lower and upper bounds.

    Args:
        x: Number to clamp.
        lower: Lower bound.
        upper: Upper bound

    Returns:
        number

    Example:

        >>> clamp(-10, -5, 5)
        -5
        >>> clamp(10, -5, 5)
        5
        >>> clamp(10, 5)
        5
        >>> clamp(-10, 5)
        -10

    .. versionadded:: 4.0.0
    r2   )rh   loweruppers      r6   r   r   H  s9    2 }5y H 
UHr8   c                :    t        | |t        j                  d      S )a  
    Divide two numbers.

    Args:
        dividend: The first number in a division.
        divisor: The second number in a division.

    Returns:
        Returns the quotient.

    Example:

        >>> divide(20, 5)
        4.0
        >>> divide(1.5, 3)
        0.5
        >>> divide(None, None)
        1.0
        >>> divide(5, None)
        5.0

    .. versionadded:: 4.0.0
    r   )call_math_operatoroperatortruediv)dividenddivisors     r6   r   r   m  s    0 h1A1A1EEr8   c                8    t        t        j                  | |      S )as  
    Round number down to precision.

    Args:
        x: Number to round down.
        precision: Rounding precision. Defaults to ``0``.

    Returns:
        Number rounded down.

    Example:

        >>> floor(3.75) == 3.0
        True
        >>> floor(3.215, 1) == 3.2
        True
        >>> floor(0.046, 2) == 0.04
        True

    .. versionadded:: 3.3.0
    )re   rf   r   rg   s     r6   r   r     s    , 4::q),,r8   c                     y r1   r2   r=   defaults     r6   r   r          !$r8   c                     y r1   r2   rx   s     r6   r   r          -0r8   c                     y r1   r2   rx   s     r6   r   r     rz   r8   c                     y r1   r2   rx   s     r6   r   r     r|   r8   c                    t        | |      S )a  
    Retrieves the maximum value of a `collection`.

    Args:
        collection: Collection to iterate over.
        default: Value to return if `collection` is empty.

    Returns:
        Maximum value.

    Example:

        >>> max_([1, 2, 3, 4])
        4
        >>> max_([], default=-1)
        -1

    .. versionadded:: 1.0.0

    .. versionchanged:: 4.0.0
        Moved iteratee iteratee support to :func:`max_by`.
    ry   )r   rx   s     r6   r   r         . *g..r8   c                     y r1   r2   r=   rC   ry   s      r6   r   r         
 !$r8   c                     y r1   r2   r   s      r6   r   r         
 
r8   c                    y r1   r2   r   s      r6   r   r          r8   c                    y r1   r2   r   s      r6   r   r     r|   r8   c                     y r1   r2   r   s      r6   r   r     rz   r8   c                     y r1   r2   r   s      r6   r   r     r   r8   c                    y r1   r2   r   s      r6   r   r           r8   c                    y r1   r2   r   s      r6   r   r     r|   r8   c                     y r1   r2   r   s      r6   r   r         \_r8   c                     y r1   r2   r   s      r6   r   r         ^ar8   c                    t        | t              r| j                         } t        t	        | |      t        j                  |            S )a  
    Retrieves the maximum value of a `collection`.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.
        default: Value to return if `collection` is empty.

    Returns:
        Maximum value.

    Example:

        >>> max_by([1.0, 1.5, 1.8], math.floor)
        1.0
        >>> max_by([{"a": 1}, {"a": 2}, {"a": 3}], "a")
        {'a': 3}
        >>> max_by([], default=-1)
        -1

    .. versionadded:: 4.0.0
    key)
isinstancedictvaluesmaxr   pydrC   r   s      r6   r   r     s:    . *d#&&(
$Z9s||H?UVVr8   c                     y r1   r2   rB   s     r6   r   r   1       r8   c                     y r1   r2   rB   s     r6   r   r   7  r   r8   c                     y r1   r2   rB   s     r6   r   r   =  r   r8   c                     y r1   r2   rB   s     r6   r   r   C  r   r8   c                     y r1   r2   rB   s     r6   r   r   I  r   r8   c                     y r1   r2   rB   s     r6   r   r   O  r   r8   c                     y r1   r2   rB   s     r6   r   r   U  s    [^r8   c                   t        |       }|dz   dz  }t        d t        | |      D              } t        j                  |      r| t        |dz
           }|S t        |dz
        }t        |dz
        }| |   | |   z   dz  }|S )a  
    Calculate median of each element in `collection`. If iteratee is passed, each element of
    `collection` is passed through an iteratee before the median is computed.

    Args:
        collection: Collection to process.
        iteratee: Iteratee applied per iteration.

    Returns:
        Result of median.

    Example:

        >>> median([1, 2, 3, 4, 5])
        3
        >>> median([1, 2, 3, 4])
        2.5

    .. versionadded:: 2.1.0
    r      c              3  &   K   | ]	  }|d      ywrO   r2   )rP   rets     r6   rR   zmedian.<locals>.<genexpr>p  s     M3AMrS   g      ?g      ?)rc   sortedr	   r   is_oddint)r=   rC   lengthmiddlerQ   leftrights          r6   r   r   Y  s    * _FqjAFM,z8*LMMJ
zz&C
O, M	 6C< FSL!T"Z%66!;Mr8   c                     y r1   r2   rx   s     r6   r   r   |  rz   r8   c                     y r1   r2   rx   s     r6   r   r     r|   r8   c                     y r1   r2   rx   s     r6   r   r     rz   r8   c                     y r1   r2   rx   s     r6   r   r     r|   r8   c                    t        | |      S )a  
    Retrieves the minimum value of a `collection`.

    Args:
        collection: Collection to iterate over.
        default: Value to return if `collection` is empty.

    Returns:
        Minimum value.

    Example:

        >>> min_([1, 2, 3, 4])
        1
        >>> min_([], default=100)
        100

    .. versionadded:: 1.0.0

    .. versionchanged:: 4.0.0
        Moved iteratee iteratee support to :func:`min_by`.
    r   )r   rx   s     r6   r   r     r   r8   c                     y r1   r2   r   s      r6   r   r     r   r8   c                     y r1   r2   r   s      r6   r   r     r   r8   c                    y r1   r2   r   s      r6   r   r     r   r8   c                    y r1   r2   r   s      r6   r   r     r|   r8   c                     y r1   r2   r   s      r6   r   r     rz   r8   c                     y r1   r2   r   s      r6   r   r     r   r8   c                    y r1   r2   r   s      r6   r   r     r   r8   c                    y r1   r2   r   s      r6   r   r     r|   r8   c                     y r1   r2   r   s      r6   r   r     r   r8   c                     y r1   r2   r   s      r6   r   r     r   r8   c                    t        | t              r| j                         } t        t	        | |      t        j                  |            S )a  
    Retrieves the minimum value of a `collection`.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.
        default: Value to return if `collection` is empty.

    Returns:
        Minimum value.

    Example:

        >>> min_by([1.8, 1.5, 1.0], math.floor)
        1.8
        >>> min_by([{"a": 1}, {"a": 2}, {"a": 3}], "a")
        {'a': 1}
        >>> min_by([], default=100)
        100

    .. versionadded:: 4.0.0
    r   )r   r   r   minr   r   rC   r   s      r6   r   r     s:    . *d#&&(
$Z9s||H?UVVr8   c                    g }t        |      }t        |dz
  t        |       dz         D ]3  }| ||z
  | }t        |      |k(  s|j                  t	        |             5 |S )a;  
    Calculate moving mean of each element of `array`.

    Args:
        array: List to process.
        size: Window size.

    Returns:
        Result of moving average.

    Example:

        >>> moving_mean(range(10), 1)
        [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
        >>> moving_mean(range(10), 5)
        [2.0, 3.0, 4.0, 5.0, 6.0, 7.0]
        >>> moving_mean(range(10), 10)
        [4.5]

    .. versionadded:: 2.1.0

    .. versionchanged:: 4.0.0
        Rename to ``moving_mean`` and remove ``moving_average`` and ``moving_avg`` aliases.
    r   )r   rangerc   appendr   )arraysizerQ   iwindows        r6   r   r     sg    2 Ft9D4!8SZ!^, (q4x!$v;$MM$v,'	( Mr8   c                     y r1   r2   
multipliermultiplicands     r6   r    r    0      JMr8   c                     y r1   r2   r   s     r6   r    r    4  r   r8   c                     y r1   r2   r   s     r6   r    r    8  s    ;>r8   c                     y r1   r2   r   s     r6   r    r    <      EHr8   c                     y r1   r2   r   s     r6   r    r    @  r   r8   c                :    t        | |t        j                  d      S )a  
    Multiply two numbers.

    Args:
        multiplier: The first number in a multiplication.
        multiplicand: The second number in a multiplication.

    Returns:
        Returns the product.

    Example:

        >>> multiply(4, 5)
        20
        >>> multiply(10, 4)
        40
        >>> multiply(None, 10)
        10
        >>> multiply(None, None)
        1

    .. versionadded:: 4.0.0
    r   )rq   rr   mulr   s     r6   r    r    D  s    0 j,aHHr8   c                     y r1   r2   rh   ns     r6   r!   r!   _  s    25r8   c                     y r1   r2   r   s     r6   r!   r!   c  s    69r8   c                     y r1   r2   r   s     r6   r!   r!   g      BEr8   c                     y r1   r2   r   s     r6   r!   r!   k  s    NQr8   c                    t        j                  |       rt        | |      }|S t        j                  |       r| D cg c]  }t        ||       }}|S d}|S c c}w )aa  
    Calculate exponentiation of `x` raised to the `n` power.

    Args:
        x: Base number.
        n: Exponent.

    Returns:
        Result of calculation.

    Example:

        >>> power(5, 2)
        25
        >>> power(12.5, 3)
        1953.125

    .. versionadded:: 2.1.0

    .. versionchanged:: 4.0.0
        Removed alias ``pow_``.
    N)r   	is_numberpowis_list)rh   r   rQ   items       r6   r!   r!   o  s`    . }}QQ M 
Q+,-4#dA,-- M M	 .s   Ac                     y r1   r2   rg   s     r6   r"   r"     s    TWr8   c                     y r1   r2   rg   s     r6   r"   r"     r>   r8   c                $    t        t        | |      S )au  
    Round number to precision.

    Args:
        x: Number to round.
        precision: Rounding precision. Defaults to ``0``.

    Returns:
        Rounded number.

    Example:

        >>> round_(3.275) == 3.0
        True
        >>> round_(3.275, 1) == 3.3
        True

    .. versionadded:: 2.1.0

    .. versionchanged:: 4.0.0
        Remove alias ``curve``.
    )re   roundrg   s     r6   r"   r"     s    . 5!Y''r8   c                     y r1   r2   r   maximums     r6   r#   r#     s    RUr8   c                     y r1   r2   r   s     r6   r#   r#     r   r8   c                     y r1   r2   r   s     r6   r#   r#     r   r8   c                R    t        |       }||z  }| D cg c]  }||z  	 c}S c c}w )a  
    Scale list of value to a maximum number.

    Args:
        array: Numbers to scale.
        maximum: Maximum scale value.

    Returns:
        Scaled numbers.

    Example:

        >>> scale([1, 2, 3, 4])
        [0.25, 0.5, 0.75, 1.0]
        >>> scale([1, 2, 3, 4], 1)
        [0.25, 0.5, 0.75, 1.0]
        >>> scale([1, 2, 3, 4], 4)
        [1.0, 2.0, 3.0, 4.0]
        >>> scale([1, 2, 3, 4], 2)
        [0.5, 1.0, 1.5, 2.0]

    .. versionadded:: 2.1.0
    )r   )r   r   	array_maxfactorr   s        r6   r#   r#     s/    0 E
Iy F&+,dD6M,,,s   $c                     y r1   r2   point1point2s     r6   r$   r$     s     r8   c                     y r1   r2   r   s     r6   r$   r$     rY   r8   c                ^    | d   | d   }}|d   |d   }}||k(  rt         }|S ||z
  ||z
  z  }|S )a(  
    Calculate the slope between two points.

    Args:
        point1: X and Y coordinates of first point.
        point2: X and Y cooredinates of second point.

    Returns:
        Calculated slope.

    Example:

        >>> slope((1, 2), (4, 8))
        2.0

    .. versionadded:: 2.1.0
    r   r   )INFINITY)r   r   x1y1x2y2rQ   s          r6   r$   r$     sR    $ AYq	BAYq	B	Rx M r'b2g&Mr8   c                >    t        j                  t        |             S )aN  
    Calculate standard deviation of list of numbers.

    Args:
        array: List to process.

    Returns:
        Calculated standard deviation.

    Example:

        >>> round(std_deviation([1, 18, 20, 4]), 2) == 8.35
        True

    .. versionadded:: 2.1.0

    .. versionchanged:: 4.0.0
        Remove alias ``sigma``.
    )rf   sqrtr*   r   s    r6   r%   r%     s    ( 99Xe_%%r8   c                     y r1   r2   minuend
subtrahends     r6   r(   r(     r   r8   c                     y r1   r2   r   s     r6   r(   r(   !  r   r8   c                :    t        | |t        j                  d      S )at  
    Subtracts two numbers.

    Args:
        minuend: Value passed in by the user.
        subtrahend: Value passed in by the user.

    Returns:
        Result of the difference from the given values.

    Example:

        >>> subtract(10, 5)
        5
        >>> subtract(-10, 4)
        -14
        >>> subtract(2, 0.5)
        1.5

    .. versionadded:: 4.0.0
    r   )rq   rr   subr   s     r6   r(   r(   %  s    , gz8<<CCr8   c                    g }t        |       D ]1  \  }}t        |      D ]  \  }}t        j                  |||g|      }  3 |S )a  
    Transpose the elements of `array`.

    Args:
        array: List to process.

    Returns:
        Transposed list.

    Example:

        >>> transpose([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
        [[1, 4, 7], [2, 5, 8], [3, 6, 9]]

    .. versionadded:: 2.1.0
    )r   r   set_)r   transyrowrh   cols         r6   r)   r)   >  sT    "  "E5/ 13sm 	1FAsHHUQFC0E	11 Lr8   c                     y r1   r2   r   s    r6   r*   r*   X  s    KNr8   c                     y r1   r2   r   s    r6   r*   r*   \  r   r8   c                    t        |       fd}t        j                  |       j                  |      j                         j	                         S )z
    Calculate the variance of the elements in `array`.

    Args:
        array: List to process.

    Returns:
        Calculated variance.

    Example:

        >>> variance([1, 18, 20, 4])
        69.6875

    .. versionadded:: 2.1.0
    c                "    t        | z
  d      S )Nr   )r!   )rh   avgs    r6   varzvariance.<locals>.vars  s    QWa  r8   )r   r   _map_value)r   r
  r	  s     @r6   r*   r*   `  s@    " u+C! 55<S!&&(..00r8   c                     y r1   r2   rB   s     r6   r+   r+   y       r8   c                     y r1   r2   rB   s     r6   r+   r+     r  r8   c                     y r1   r2   rB   s     r6   r+   r+     r  r8   c                     y r1   r2   rB   s     r6   r+   r+     r  r8   c                     y r1   r2   rB   s     r6   r+   r+     s    adr8   c                     y r1   r2   rB   s     r6   r+   r+     r   r8   c                     y r1   r2   rB   s     r6   r+   r+     s    UXr8   c                    t        j                  | |      }t        |      }t        |      }|D cg c]
  }||z
  |z   c}S c c}w )a  
    Calculate the standard score assuming normal distribution. If iteratee is passed, each element
    of `collection` is passed through an iteratee before the standard score is computed.

    Args:
        collection: Collection to process.
        iteratee: Iteratee applied per iteration.

    Returns:
        Calculated standard score.

    Example:

        >>> results = zscore([1, 2, 3])

        # [-1.224744871391589, 0.0, 1.224744871391589]

    .. versionadded:: 2.1.0
    )r   r  r   r%   )r=   rC   r   r	  sigr   s         r6   r+   r+     sD    ( HHZ*E
u+C

C+014TCZ3111s   Ac                    | |} ||}t        j                  |       s	 t        |       } t        j                  |      s	 t        |      } || |      S # t        $ r Y 5w xY w# t        $ r Y #w xY w)z<Return the result of the math operation on the given values.)r   r   float	Exception)value1value2opry   s       r6   rq   rq     s    ~~== 	6]F == 	6]F ff  		  		s#   A  A# 	A A #	A/.A/c                     t        d       fd}d }t        j                  |      r
 ||      }|S t        j                  |      r	 |D cg c]
  } ||       }}|S |S c c}w # t        $ r Y |S w xY w)N
   c                      | z        z  S r1   r2   )r   funcri   s    r6   rounder_funczrounder.<locals>.rounder_func  s    D9$%	11r8   )r   r   r   is_iterable	TypeError)r!  rh   ri   r"  rQ   r   s   ` `   r6   re   re     s    B	"I2 F
}}Qa M 
		567Tl4(7F7 M6M	 8 	M	s$   A* A%A* %A* *	A76A7)r4   'SupportsAdd[T, T2]'r5   r,   returnr-   )r4   r,   r5   r%  r&  r-   )r=   't.Mapping[t.Any, 'SupportsAdd[int, T]']r&  r,   )r=   !t.Iterable['SupportsAdd[int, T]']r&  r,   )r=   t.Mapping[T, T2]rC   z:t.Callable[[T2, T, t.Dict[T, T2]], 'SupportsAdd[int, T3]']r&  r.   )r=   r)  rC   z+t.Callable[[T2, T], 'SupportsAdd[int, T3]']r&  r.   )r=   t.Mapping[t.Any, T2]rC   z(t.Callable[[T2], 'SupportsAdd[int, T3]']r&  r.   )r=   t.Iterable[T]rC   z7t.Callable[[T, int, t.List[T]], 'SupportsAdd[int, T2]']r&  r-   )r=   r+  rC   z,t.Callable[[T, int], 'SupportsAdd[int, T2]']r&  r-   )r=   r+  rC   z't.Callable[[T], 'SupportsAdd[int, T2]']r&  r-   r1   )r=   r'  rC   Noner&  r,   )r=   r(  rC   r,  r&  r,   )r=   +t.Mapping[t.Any, 'SupportsAdd[int, t.Any]']r&  r  )r=   %t.Iterable['SupportsAdd[int, t.Any]']r&  r  )r=   r)  rC   z=t.Callable[[T2, T, t.Dict[T, T2]], 'SupportsAdd[int, t.Any]']r&  r  )r=   r)  rC   z.t.Callable[[T2, T], 'SupportsAdd[int, t.Any]']r&  r  )r=   r*  rC   z+t.Callable[[T2], 'SupportsAdd[int, t.Any]']r&  r  )r=   r+  rC   z:t.Callable[[T, int, t.List[T]], 'SupportsAdd[int, t.Any]']r&  r  )r=   r+  rC   z/t.Callable[[T, int], 'SupportsAdd[int, t.Any]']r&  r  )r=   r+  rC   z*t.Callable[[T], 'SupportsAdd[int, t.Any]']r&  r  )r=   r-  rC   r,  r&  r  )r=   r.  rC   r,  r&  r  )r   )rh   r   ri   r   r&  r  )rh   rj   rn   rk   ro   zt.Union[NumT3, None]r&  zt.Union[NumT, NumT2, NumT3])rt   t.Union[NumberT, None]ru   r/  r&  r  )r=   +t.Mapping[t.Any, 'SupportsRichComparisonT']ry   r   r&  'SupportsRichComparisonT')r=   r0  ry   r,   r&  %t.Union['SupportsRichComparisonT', T])r=   %t.Iterable['SupportsRichComparisonT']ry   r   r&  r1  )r=   r3  ry   r,   r&  r2  )r=   r0  rC   r,  ry   r   r&  r1  )r=   r*  rC   +t.Callable[[T2], 'SupportsRichComparisonT']ry   r   r&  r-   )r=   r*  rC   r4  ry   r,   r&  t.Union[T2, T])r=   r0  rC   r,  ry   r,   r&  r2  )r=   r3  rC   r,  ry   r   r&  r1  )r=   t.Iterable[T2]rC   r4  ry   r   r&  r-   )r=   r6  rC   r4  ry   r,   r&  r5  )r=   r3  rC   r,  ry   r,   r&  r2  )r=   r+  rC   r
   ry   r   r&  r,   )r=   r+  rC   r
   ry   r-   r&  zt.Union[T, T2])r=   r)  rC   +t.Callable[[T2, T, t.Dict[T, T2]], NumberT]r&  t.Union[float, int])r=   r)  rC   t.Callable[[T2, T], NumberT]r&  r8  )r=   r*  rC   t.Callable[[T2], NumberT]r&  r8  )r=   r+  rC   (t.Callable[[T, int, t.List[T]], NumberT]r&  r8  )r=   r+  rC   t.Callable[[T, int], NumberT]r&  r8  )r=   r+  rC   t.Callable[[T], NumberT]r&  r8  )r=   t.Iterable[NumberT]rC   r,  r&  r8  )r   z%t.Sequence['SupportsAdd[int, t.Any]']r   zt.SupportsIntr&  t.List[float])r   SupportsMul[int, T2]r   r,  r&  r-   )r   r,  r   r@  r&  r-   )r   r,  r   r,  r&  r   )r   SupportsMul[T, T2]r   r,   r&  r-   )r   r,   r   rA  r&  r-   )rh   r   r   r   r&  t.Union[int, float])rh   r  r   rB  r&  r  )rh   zt.List[int]r   r   r&  t.List[t.Union[int, float]])rh   r?  r   rC  r&  r?  )rh   zt.List[SupportsRound[NumberT]]ri   r   r&  r?  )rh   zSupportsRound[NumberT]ri   r   r&  r  )r   zt.Iterable['Decimal']r   	'Decimal'r&  zt.List['Decimal'])r   zt.Iterable[NumberNoDecimalT]r   r   r&  r?  )r   )r   r>  r   r   r&  r?  )r   r   )r   9t.Union[t.Tuple['Decimal', 'Decimal'], t.List['Decimal']]r   rE  r&  rD  )r   Nt.Union[t.Tuple[NumberNoDecimalT, NumberNoDecimalT], t.List[NumberNoDecimalT]]r   rF  r&  r  )r   zt.List[NumberT]r&  r  )r   'SupportsSub[T, T2]'r   r,   r&  r-   )r   r,   r   rG  r&  r-   )r   zt.Iterable[t.Iterable[T]]r&  zt.List[t.List[T]])r   r-  r&  r  )r   r.  r&  r  )r=   r)  rC   r7  r&  r?  )r=   r)  rC   r9  r&  r?  )r=   r*  rC   r:  r&  r?  )r=   r+  rC   r;  r&  r?  )r=   r+  rC   r<  r&  r?  )r=   r+  rC   r=  r&  r?  )r=   r>  rC   r,  r&  r?  )C__doc__
__future__r   rf   rr   typingtpydashr   helpersr   r   r   r   r	   typesr
   r   r   r   r   TYPE_CHECKINGdecimalr   	_typeshedr   r   r   __all__TypeVarr,   r-   r.   r  r   overloadr   r&   r'   r   r   r   r   rj   rk   rl   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r(   r)   r*   r+   rq   re   r2   r8   r6   <module>rU     s1   #     P P V V ??KK8 AIIcNQYYt_QYYt_ <  1  1  1  16  G  G  A  A6  H    ,W 
 $0X 
 )` 
 )U 
  c  c  `  `  Z  ZK,  O  O  I  I2  K    ,Z
 
 $0[
 
 )c
 
 )X
 
 )S
 
 NR;GK
 
  c  c:,,2 qyyeY/		'3y1		'3y1"JF6-2 NS$;$FK$$ $
 0;0FG0*0 0
 HM$5$@E$$ $
 050@A0*0 0
 # /4  $;$$ $ 	$ $  $9  	  $9 	
   NR0;0GK0`a0*0 0
 HL_d$5$AE$W\$$ $
  9  	  *Ucd 
 HL050AE0Z[0*0 0
 OT _  _  a  a !%e W:  ,W 
  ,H 
 $0I 
 )Q 
 )F 
 )A 
  ^  ^ F NS$;$FK$$ $
 0;0FG0*0 0
 HM$5$@E$$ $
 050@A0*0 0
 # /4  $;$$ $ 	$ $  $9  	  $9 	
   NR0;0GK0`a0*0 0
 HL_d$5$AE$W\$$ $
  9  	  *Ucd 
 HL050AE0Z[0*0 0
 OT _  _  a  a !%e W8"J  M  M  M  M  >  >  H  H  H  HI6  5  5  9  9  E  E  Q  QB  W  W  G  G(4  U  U  _  _  M  M-: EE   ZZ  :&.  E  E  E  ED24  N  N  H  H12  ,W 
  ,H 
 $0I 
 )Q 
  d  d  _  _  X  X2@.r8   