Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/pandas/core/ops/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/pandas/core/ops/__pycache__/missing.cpython-312.pyc

�

Mٜg��F�dZddlmZddlZddlZddlmZdd�Zd	d�Z	d�Z
y)
aP
Missing data handling for arithmetic operations.

In particular, pandas conventions regarding division by zero differ
from numpy in the following ways:
    1) np.array([-1, 0, 1], dtype=dtype1) // np.array([0, 0, 0], dtype=dtype2)
       gives [nan, nan, nan] for most dtype combinations, and [0, 0, 0] for
       the remaining pairs
       (the remaining being dtype1==dtype2==intN and dtype==dtype2==uintN).

       pandas convention is to return [-inf, nan, inf] for all dtype
       combinations.

       Note: the numpy behavior described here is py3-specific.

    2) np.array([-1, 0, 1], dtype=dtype1) % np.array([0, 0, 0], dtype=dtype2)
       gives precisely the same results as the // operation.

       pandas convention is to return [nan, nan, nan] for all dtype
       combinations.

    3) divmod behavior consistent with 1) and 2).
�)�annotationsN)�	roperatorc��|jjdk(r|St|d�}t|tj
�}|s|s|S|rt	j|�}|jjdvrf|dk(}|j�rQ|t	j|�z}|jdd��}t	j||tj�|S)z�
    If this is a reversed op, then flip x,y

    If we have an integer value (or array in y)
    and we have 0's, fill them with np.nan,
    return the result.

    Mask the nan's from x.
    �f�dtype�iur�float64F��copy)r�kind�hasattr�
isinstance�np�ndarray�array�any�isnan�astype�putmask�nan)�result�x�y�is_variable_type�is_scalar_type�ymask�masks       �B/usr/local/lib/python3.12/site-packages/pandas/core/ops/missing.py�_fill_zerosr!s����|�|���C���
��q�'�*��#�A�r�z�z�2�2�N��N��
���H�H�Q�K���w�w�|�|�t���Q����9�9�;��B�H�H�V�,�,�,�D��]�]�9�5�]�9�F��J�J�v�t�R�V�V�,��M�c�:�t|d�stj|�}t|d�stj|�}|dk(}|j�r�|tj|�z}||z}|dk}|dkD}||dk(z}||z||zz}	||z||zz}
|j�s |	j�s|
j�rM|jdd��}tj||<tj||
<tj||	<|S)am
    Set results of  0 // 0 to np.nan, regardless of the dtypes
    of the numerator or the denominator.

    Parameters
    ----------
    x : ndarray
    y : ndarray
    result : ndarray

    Returns
    -------
    ndarray
        The filled result.

    Examples
    --------
    >>> x = np.array([1, 0, -1], dtype=np.int64)
    >>> x
    array([ 1,  0, -1])
    >>> y = 0       # int 0; numpy behavior is different with float
    >>> result = x // y
    >>> result      # raw numpy result does not fill division by zero
    array([0, 0, 0])
    >>> mask_zero_div_zero(x, y, result)
    array([ inf,  nan, -inf])
    rrr	Fr
)r
rrr�signbitrr�inf)rrr�zmask�	zneg_mask�	zpos_mask�x_lt0�x_gt0�nan_mask�neginf_mask�posinf_masks           r�mask_zero_div_zeror,Gs��:�1�g���H�H�Q�K���1�g���H�H�Q�K��
��F�E��y�y�{��B�J�J�q�M�)�	��Y�J�&�	��A����A����A��F�#�� �5�(�Y��->�?�� �5�(�Y��->�?���<�<�>�[�_�_�.�+�/�/�2C��]�]�9�5�]�9�F�!�v�v�F�8��"$�&�&�F�;��#%�6�6�'�F�;���Mr c���|tur"t|||d�t|d||�f}|S|tjur"t|||d�t|d||�f}|S|t
jurt|||�}|S|tjurt|||�}|S|t
jurt|||�}|S|tjur
t|||�}|S)ab
    Call _fill_zeros with the appropriate fill value depending on the operation,
    with special logic for divmod and rdivmod.

    Parameters
    ----------
    op : function (operator.add, operator.div, ...)
    left : object (np.ndarray for non-reversed ops)
        We have excluded ExtensionArrays here
    right : object (np.ndarray for reversed ops)
        We have excluded ExtensionArrays here
    result : ndarray

    Returns
    -------
    result : np.ndarray

    Notes
    -----
    For divmod and rdivmod, the `result` parameter and returned `result`
    is a 2-tuple of ndarray objects.
    r�)
�divmodr,rr�rdivmod�operator�floordiv�	rfloordiv�mod�rmod)�op�left�rightrs    r�dispatch_fill_zerosr9�s	��.
�V�|��t�U�F�1�I�6���q�	�4��/�
��*�M�#
�y� � �	 ��u�d�F�1�I�6���q�	�5�$�/�
�� �M�
�x� � �	 �$�D�%��8���M�
�y�"�"�	"�$�E�4��8��
�M�	
�x�|�|�	��V�T�5�1���M�
�y�~�~�	��V�U�D�1���Mr )r�
np.ndarray)rr:�returnr:)�__doc__�
__future__rr1�numpyr�pandas.corerrr,r9�r r�<module>rAs)���.#���!�#�L9�x-r 

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists