o
    _~#gD                     @  s   d Z ddlmZ ddlZddlmZ ddlZddlm	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZ dd
lmZ dddddZG dd dZd(ddZd)ddZd*dd Zd+d"d#Zd*d$d%Zd*d&d'ZdS ),zn
Methods that can be shared by many array-like classes or subclasses:
    Series
    Index
    ExtensionArray
    )annotationsN)Any)lib)!maybe_dispatch_ufunc_to_dunder_op)
ABCNDFrame)	roperatorextract_array)unpack_zerodim_and_defermaxminsumprod)maximumminimumaddmultiplyc                   @  s  e Zd Zdd Zeddd Zeddd Zed	d
d Zeddd Zeddd Z	eddd Z
dd Zeddd Zeddd Zeddd Zed d!d" Zed#d$d% Zed&d'd( Zd)d* Zed+d,d- Zed.d/d0 Zed1d2d3 Zed4d5d6 Zed7d8d9 Zed:d;d< Zed=d>d? Zed@dAdB ZedCdDdE ZedFdGdH ZedIdJdK ZedLdMdN ZedOdPdQ ZedRdSdT Z edUdVdW Z!edXdYdZ Z"d[S )\OpsMixinc                 C     t S NNotImplementedselfotherop r   z/var/www/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/env/lib/python3.10/site-packages/pandas/core/arraylike.py_cmp_method#      zOpsMixin._cmp_method__eq__c                 C     |  |tjS r   )r   operatoreqr   r   r   r   r   r    &      zOpsMixin.__eq____ne__c                 C  r!   r   )r   r"   ner$   r   r   r   r&   *   r%   zOpsMixin.__ne____lt__c                 C  r!   r   )r   r"   ltr$   r   r   r   r(   .   r%   zOpsMixin.__lt____le__c                 C  r!   r   )r   r"   ler$   r   r   r   r*   2   r%   zOpsMixin.__le____gt__c                 C  r!   r   )r   r"   gtr$   r   r   r   r,   6   r%   zOpsMixin.__gt____ge__c                 C  r!   r   )r   r"   ger$   r   r   r   r.   :   r%   zOpsMixin.__ge__c                 C  r   r   r   r   r   r   r   _logical_methodA   r   zOpsMixin._logical_method__and__c                 C  r!   r   )r0   r"   and_r$   r   r   r   r1   D   r%   zOpsMixin.__and____rand__c                 C  r!   r   )r0   r   rand_r$   r   r   r   r3   H   r%   zOpsMixin.__rand____or__c                 C  r!   r   )r0   r"   or_r$   r   r   r   r5   L   r%   zOpsMixin.__or____ror__c                 C  r!   r   )r0   r   ror_r$   r   r   r   r7   P   r%   zOpsMixin.__ror____xor__c                 C  r!   r   )r0   r"   xorr$   r   r   r   r9   T   r%   zOpsMixin.__xor____rxor__c                 C  r!   r   )r0   r   rxorr$   r   r   r   r;   X   r%   zOpsMixin.__rxor__c                 C  r   r   r   r   r   r   r   _arith_method_   r   zOpsMixin._arith_method__add__c                 C  r!   )a/  
        Get Addition of DataFrame and other, column-wise.

        Equivalent to ``DataFrame.add(other)``.

        Parameters
        ----------
        other : scalar, sequence, Series, dict or DataFrame
            Object to be added to the DataFrame.

        Returns
        -------
        DataFrame
            The result of adding ``other`` to DataFrame.

        See Also
        --------
        DataFrame.add : Add a DataFrame and another object, with option for index-
            or column-oriented addition.

        Examples
        --------
        >>> df = pd.DataFrame({'height': [1.5, 2.6], 'weight': [500, 800]},
        ...                   index=['elk', 'moose'])
        >>> df
               height  weight
        elk       1.5     500
        moose     2.6     800

        Adding a scalar affects all rows and columns.

        >>> df[['height', 'weight']] + 1.5
               height  weight
        elk       3.0   501.5
        moose     4.1   801.5

        Each element of a list is added to a column of the DataFrame, in order.

        >>> df[['height', 'weight']] + [0.5, 1.5]
               height  weight
        elk       2.0   501.5
        moose     3.1   801.5

        Keys of a dictionary are aligned to the DataFrame, based on column names;
        each value in the dictionary is added to the corresponding column.

        >>> df[['height', 'weight']] + {'height': 0.5, 'weight': 1.5}
               height  weight
        elk       2.0   501.5
        moose     3.1   801.5

        When `other` is a :class:`Series`, the index of `other` is aligned with the
        columns of the DataFrame.

        >>> s1 = pd.Series([0.5, 1.5], index=['weight', 'height'])
        >>> df[['height', 'weight']] + s1
               height  weight
        elk       3.0   500.5
        moose     4.1   800.5

        Even when the index of `other` is the same as the index of the DataFrame,
        the :class:`Series` will not be reoriented. If index-wise alignment is desired,
        :meth:`DataFrame.add` should be used with `axis='index'`.

        >>> s2 = pd.Series([0.5, 1.5], index=['elk', 'moose'])
        >>> df[['height', 'weight']] + s2
               elk  height  moose  weight
        elk    NaN     NaN    NaN     NaN
        moose  NaN     NaN    NaN     NaN

        >>> df[['height', 'weight']].add(s2, axis='index')
               height  weight
        elk       2.0   500.5
        moose     4.1   801.5

        When `other` is a :class:`DataFrame`, both columns names and the
        index are aligned.

        >>> other = pd.DataFrame({'height': [0.2, 0.4, 0.6]},
        ...                      index=['elk', 'moose', 'deer'])
        >>> df[['height', 'weight']] + other
               height  weight
        deer      NaN     NaN
        elk       1.7     NaN
        moose     3.0     NaN
        )r=   r"   r   r$   r   r   r   r>   b   s   XzOpsMixin.__add____radd__c                 C  r!   r   )r=   r   raddr$   r   r   r   r?      r%   zOpsMixin.__radd____sub__c                 C  r!   r   )r=   r"   subr$   r   r   r   rA      r%   zOpsMixin.__sub____rsub__c                 C  r!   r   )r=   r   rsubr$   r   r   r   rC      r%   zOpsMixin.__rsub____mul__c                 C  r!   r   )r=   r"   mulr$   r   r   r   rE      r%   zOpsMixin.__mul____rmul__c                 C  r!   r   )r=   r   rmulr$   r   r   r   rG      r%   zOpsMixin.__rmul____truediv__c                 C  r!   r   )r=   r"   truedivr$   r   r   r   rI      r%   zOpsMixin.__truediv____rtruediv__c                 C  r!   r   )r=   r   rtruedivr$   r   r   r   rK      r%   zOpsMixin.__rtruediv____floordiv__c                 C  r!   r   )r=   r"   floordivr$   r   r   r   rM      r%   zOpsMixin.__floordiv____rfloordivc                 C  r!   r   )r=   r   	rfloordivr$   r   r   r   __rfloordiv__   r%   zOpsMixin.__rfloordiv____mod__c                 C  r!   r   )r=   r"   modr$   r   r   r   rR      r%   zOpsMixin.__mod____rmod__c                 C  r!   r   )r=   r   rmodr$   r   r   r   rT      r%   zOpsMixin.__rmod__
__divmod__c                 C  s   |  |tS r   )r=   divmodr$   r   r   r   rV      s   zOpsMixin.__divmod____rdivmod__c                 C  r!   r   )r=   r   rdivmodr$   r   r   r   rX      r%   zOpsMixin.__rdivmod____pow__c                 C  r!   r   )r=   r"   powr$   r   r   r   rZ      r%   zOpsMixin.__pow____rpow__c                 C  r!   r   )r=   r   rpowr$   r   r   r   r\      r%   zOpsMixin.__rpow__N)#__name__
__module____qualname__r   r
   r    r&   r(   r*   r,   r.   r0   r1   r3   r5   r7   r9   r;   r=   r>   r?   rA   rC   rE   rG   rI   rK   rM   rQ   rR   rT   rV   rX   rZ   r\   r   r   r   r   r      sx    












Y













r   ufuncnp.ufuncmethodstrinputsr   kwargsc                   sX  ddl m}m} ddlm ddlm m t}t	di |}t
	g|R i |}|tur4|S tjj|jf}	|D ](}
t|
doI|
jjk}t|
do\t|
j|	vo\t|
j }|sa|ret  S q=tdd |D }fd	d
t||D tdkrt|}t|dkr||h|rtd	 dj}dd D ]}tt||jD ]\}\}}||||< qqttj|tfddt||D }n	ttjjjdkrdd
 |D }tt|dkr|d nd}d|ini 	fdd} fddd|v r't	g|R i |}||S dkr@t 	g|R i |}|tur@|S jdkrgt|dksS	j!dkrgtdd |D }t"	|i |}n?jdkrtdd |D }t"	|i |}n%dkr|s|d j#}|$t"	}nt%|d 	g|R i |}||}|S )z
    Compatibility with numpy ufuncs.

    See also
    --------
    numpy.org/doc/stable/reference/arrays.classes.html#numpy.class.__array_ufunc__
    r   )	DataFrameSeriesNDFrame)ArrayManagerBlockManager__array_priority____array_ufunc__c                 s  s    | ]}t |V  qd S r   )type.0xr   r   r   	<genexpr>,      zarray_ufunc.<locals>.<genexpr>c                   s   g | ]\}}t | r|qS r   )
issubclassrq   rr   tri   r   r   
<listcomp>-  s    zarray_ufunc.<locals>.<listcomp>   zCannot apply ufunc z& to mixed DataFrame and Series inputs.Nc                 3  s2    | ]\}}t | r|jdi n|V  qd S )Nr   )ru   reindexrv   )rj   reconstruct_axesr   r   rs   D  s
    
c                 S  s    g | ]}t |d rt|d qS )name)hasattrgetattrrp   r   r   r   rx   L  s     r|   c                   s(   j dkrt fdd| D S  | S )Nry   c                 3  s    | ]} |V  qd S r   r   rp   )_reconstructr   r   rs   U  rt   z3array_ufunc.<locals>.reconstruct.<locals>.<genexpr>)nouttupleresult)r   ra   r   r   reconstructR  s   
z array_ufunc.<locals>.reconstructc                   s   t | r| S | jjkrdkrt| S t|  fr%j| | jd} nj| fi ddi} tdkr?| 	} | S )Nouter)axescopyFry   )
r   	is_scalarndimNotImplementedError
isinstance_constructor_from_mgrr   _constructorlen__finalize__r   )rk   rl   	alignablerc   r{   reconstruct_kwargsr   r   r   r   Y  s(   

z!array_ufunc.<locals>._reconstructoutreducec                 s  s    | ]}t |V  qd S r   npasarrayrp   r   r   r   rs     s    c                 s  s    | ]	}t |d dV  qdS )T)extract_numpyNr   rp   r   r   r   rs     s    __call__r   )&pandas.core.framerg   rh   pandas.core.genericrj   pandas.core.internalsrk   rl   ro   _standardize_out_kwargr   r   r   ndarrayrn   r}   rm   r   _HANDLED_TYPESr   zipr   setissubsetr   r   	enumerateuniondict_AXIS_ORDERSr   dispatch_ufunc_with_outdispatch_reduction_ufuncr   r~   _mgrapplydefault_array_ufunc)r   ra   rc   re   rf   rg   rh   clsr   no_deferitemhigher_priorityhas_array_ufunctypes	set_typesr   objiax1ax2namesr|   r   mgrr   )
rk   rl   rj   r   r   rc   r{   r   r   ra   r   array_ufunc   s   









&	
r   returnr   c                  K  s@   d| vrd| v rd| v r|  d}|  d}||f}|| d< | S )z
    If kwargs contain "out1" and "out2", replace that with a tuple "out"

    np.divmod, np.modf, np.frexp can have either `out=(out1, out2)` or
    `out1=out1, out2=out2)`
    r   out1out2)pop)rf   r   r   r   r   r   r   r     s   

r   c           
      O  s   | d}| dd}t|||i |}|tu rtS t|trAt|tr-t|t|kr/tt||D ]
\}}	t||	| q4|S t|trSt|dkrQ|d }ntt||| |S )zz
    If we have an `out` keyword, then call the ufunc without `out` and then
    set the result into the given `out`.
    r   whereNry   r   )	r   r~   r   r   r   r   r   r   _assign_where)
r   ra   rc   re   rf   r   r   r   arrresr   r   r   r     s"   



r   Nonec                 C  s*   |du r|| dd< dS t | || dS )zV
    Set a ufunc result into 'out', masking with a 'where' argument if necessary.
    N)r   putmask)r   r   r   r   r   r   r     s   r   c                   s@   t  fdd|D st fdd|D }t|||i |S )z
    Fallback to the behavior we would get if we did not define __array_ufunc__.

    Notes
    -----
    We are assuming that `self` is among `inputs`.
    c                 3  s    | ]}| u V  qd S r   r   rp   r   r   r   rs     rt   z&default_array_ufunc.<locals>.<genexpr>c                   s"   g | ]}| ur
|nt |qS r   r   rp   r   r   r   rx     s   " z'default_array_ufunc.<locals>.<listcomp>)anyr   r~   )r   ra   rc   re   rf   
new_inputsr   r   r   r     s   r   c                 O  s   |dksJ t |dks|d | urtS |jtvrtS t|j }t| |s'tS | jdkr=t| tr5d|d< d|vr=d|d< t| |d	ddi|S )
z@
    Dispatch ufunc reductions to self's reduction methods.
    r   ry   r   Fnumeric_onlyaxisskipnaNr   )	r   r   r^   REDUCTION_ALIASESr}   r   r   r   r~   )r   ra   rc   re   rf   method_namer   r   r   r     s   




r   )ra   rb   rc   rd   re   r   rf   r   )r   r   )ra   rb   rc   rd   )r   r   )__doc__
__future__r   r"   typingr   numpyr   pandas._libsr   pandas._libs.ops_dispatchr   pandas.core.dtypes.genericr   pandas.corer   pandas.core.constructionr	   pandas.core.ops.commonr
   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s2     
_ 
&

#
