
    h!                    |    d Z ddlmZ ddlZddlmZmZ 	 	 	 	 	 	 	 	 d	dZ		 	 	 	 	 	 	 	 d	dZ
	 	 	 	 	 	 	 	 d
dZddZy)z
Ops for masked arrays.
    )annotationsN)libmissingc                   |t        || ||      S t        | t        j                        st	        d      t        |d       |t        j                  u r| j                         }n| |z  }|!| |z   }||z   }||z  ||z  z  ||z  z  }||fS |du rt        j                  |      }||fS |t        j                  u r|  | z  |z  }||fS |j                         }||fS )a  
    Boolean ``or`` using Kleene logic.

    Values are NA where we have ``NA | NA`` or ``NA | False``.
    ``NA | True`` is considered True.

    Parameters
    ----------
    left, right : ndarray, NA, or bool
        The values of the array.
    left_mask, right_mask : ndarray, optional
        The masks. Only one of these may be None, which implies that
        the associated `left` or `right` value is a scalar.

    Returns
    -------
    result, mask: ndarray[bool]
        The result of the logical or, and the new mask.
    1Either `left` or `right` need to be a np.ndarray.ormethodT)
	kleene_or
isinstancenpndarray	TypeErrorraise_for_nan
libmissingNAcopy
zeros_like)leftright	left_mask
right_maskresult
left_falseright_falsemasks           =D:\jyotish\venv\Lib\site-packages\pandas/core/ops/mask_ops.pyr   r      s   8 j)<<dBJJ'KLL%%
i'(

*+*$Y&(:%' 	 4< D===+D 4< jmm#EYJ&)3D
 4< >>#D4<    c                t   |t        || ||      S t        | t        j                        st	        d      t        |d       |t        j                  u rt        j                  |       }n| |z  }|?|t        j                  u rt        j                  |      }||fS |j                         }||fS ||z  }||fS )a'  
    Boolean ``xor`` using Kleene logic.

    This is the same as ``or``, with the following adjustments

    * True, True -> False
    * True, NA   -> NA

    Parameters
    ----------
    left, right : ndarray, NA, or bool
        The values of the array.
    left_mask, right_mask : ndarray, optional
        The masks. Only one of these may be None, which implies that
        the associated `left` or `right` value is a scalar.

    Returns
    -------
    result, mask: ndarray[bool]
        The result of the logical xor, and the new mask.
    r   xorr	   )
kleene_xorr   r   r   r   r   r   r   r   	ones_liker   )r   r   r   r   r   r   s         r   r!   r!   L   s    < %z9==dBJJ'KLL%&
t$JMM!<<	*D 4<	 >>#D 4< :%4<r   c                   |t        || ||      S t        | t        j                        st	        d      t        |d       |t        j                  u rt        j                  |       }n| |z  }|<|t        j                  u r| | z  |z  }||fS |j                         }|du rd|dd ||fS | |z   }||z   }|| z  || z  z  }||fS )a  
    Boolean ``and`` using Kleene logic.

    Values are ``NA`` for ``NA & NA`` or ``True & NA``.

    Parameters
    ----------
    left, right : ndarray, NA, or bool
        The values of the array.
    left_mask, right_mask : ndarray, optional
        The masks. Only one of these may be None, which implies that
        the associated `left` or `right` value is a scalar.

    Returns
    -------
    result, mask: ndarray[bool]
        The result of the logical xor, and the new mask.
    Nr   andr	   F)

kleene_andr   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   s           r   r%   r%      s    6 %z9==dBJJ'KLL%&
t$JMM!I:%2D 4< >>#D~Q 4<	 i'(

*+[L(Z:+-EF4<r   c                x    t        j                  |       r%t        j                  |       rt	        d| d      y y )NzCannot perform logical 'z' with floating NaN)r   is_floatr   isnan
ValueError)valuer
   s     r   r   r      s6    
||Erxx3F8;NOPP  /r   )r   %bool | np.ndarray | libmissing.NATyper   r+   r   np.ndarray | Noner   r,   )r   %bool | libmissing.NAType | np.ndarrayr   r-   r   r,   r   r,   )r
   strreturnNone)__doc__
__future__r   numpyr   pandas._libsr   r   r   r   r!   r%   r    r   r   <module>r6      s    # ;
/;0; !; "	;|2
/202 !2 "	2j7
/707 !7 "	7tQr   