
    Mh0                       S SK Jr  S SKrS SKJrJrJr  S SKrS SK	J
r
Jr  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJrJr  \(       a  S SKrS SKJrJrJrJrJ r   \ " S S\5      5       r! S   SS jjr" " S S\5      r#g)    )annotationsN)TYPE_CHECKINGClassVarcast)libmissing)is_list_like)register_extension_dtype)isna)ops)masked_accumulations)BaseMaskedArrayBaseMaskedDtype)DtypeDtypeObjSelfnpttype_tc                      \ rS rSr% SrSrS\S'   \SS j5       r\SS j5       r	\SS j5       r
\SS	 j5       rSS
 jr\SS j5       r\SS j5       r    SS jrSrg)BooleanDtype(   a  
Extension dtype for boolean data.

.. warning::

   BooleanDtype is considered experimental. The implementation and
   parts of the API may change without warning.

Attributes
----------
None

Methods
-------
None

Examples
--------
>>> pd.BooleanDtype()
BooleanDtype
booleanzClassVar[str]namec                "    [         R                  $ N)npbool_selfs    L/var/www/html/env/lib/python3.13/site-packages/pandas/core/arrays/boolean.pytypeBooleanDtype.typeD   s    xx    c                    g)Nb r   s    r    kindBooleanDtype.kindH   s    r#   c                .    [         R                  " S5      $ )Nbool)r   dtyper   s    r    numpy_dtypeBooleanDtype.numpy_dtypeL   s    xxr#   c                    [         $ )zI
Return the array type associated with this dtype.

Returns
-------
type
)BooleanArray)clss    r    construct_array_type!BooleanDtype.construct_array_typeP   s
     r#   c                    g)Nr   r&   r   s    r    __repr__BooleanDtype.__repr__[   s    r#   c                    gNTr&   r   s    r    _is_booleanBooleanDtype._is_boolean^       r#   c                    gr7   r&   r   s    r    _is_numericBooleanDtype._is_numericb   r:   r#   c                    SSK nUR                  UR                  " 5       :w  aC  UR                  R	                  UR                  5      (       d  [        SUR                   S35      e[        XR                  5      (       a  U/n[        U5      nOUR                  nUR                  5       nUR                  R	                  UR                  5      (       a=  [        R                  " U[        S9n[        R                  " U[        S9n[        Xe5      $ / nU H  nUR!                  5       n	UR                  R#                  UR                  [        U5      SU	S   /UR$                  S9R'                  SS	9nUR(                  S:w  aO  UR                  R#                  UR                  [        U5      SU	S   /UR$                  S9R'                  SS	9nU) nO"[        R*                  " [        U5      [        S9n[        Xe5      n
UR-                  U
5        M     U(       dN  [        [        R.                  " / [        R                  S9[        R.                  " / [        R                  S95      $ [        R1                  U5      $ )
z9
Construct BooleanArray from pyarrow Array/ChunkedArray.
r   Nz$Expected array of boolean type, got z insteadr+      )offsetF)zero_copy_only)pyarrowr!   r   typesis_null	TypeError
isinstanceArraylenchunkslengthr   onesr*   emptyr/   buffersfrom_buffersrA   to_numpy
null_countzerosappendarray_concat_same_type)r   rT   rC   rJ   rK   maskdataresultsarrbuflistbool_arrs              r    __from_arrow__BooleanDtype.__from_arrow__f   s    	::(1F1Fuzz1R1RB5::,hWXXe]]++WFZF \\F\\^F==  ,,776.D88F$/D++CkkmG''44#c(T71:$6szz 5 heh,  ~~"++88HHc#hwqz(:3:: 9 (%(0  uxxC5#D/HNN8$   288,bhhr.J   11'::r#   r&   N)returnr!   )r^   str)r^   znp.dtype)r^   ztype_t[BooleanArray]r^   r*   )rT   z$pyarrow.Array | pyarrow.ChunkedArrayr^   r/   )__name__
__module____qualname____firstlineno____doc__r   __annotations__propertyr!   r'   r,   classmethodr1   r4   r8   r<   r\   __static_attributes__r&   r#   r    r   r   (   s    , $D-#              /;9/;	/;r#   r   c                   [        U [        5      (       aO  Ub  [        S5      eU R                  U R                  pU(       a   U R                  5       n UR                  5       nX4$ Sn[        U [        R                  5      (       a7  U R                  [        R                  :X  a  U(       a  U R                  5       n GO[        U [        R                  5      (       a  U R                  R                  S;   a  [        U 5      n[        R                  " [        U 5      [        S9nX)    R                  [        5      XC) '   [        R                   " XC)    R                  U R                  5      X)    :H  5      (       d  [#        S5      eUn O[        R$                  " U [&        S9n[(        R*                  " USS9nSnUS	U-   ;  a  [#        S5      e[-        S
[        U5      5      n[        R                  " [        U 5      [        S9n XS)    R                  [        5      X) '   Xg;   aU  [        R                   " X)    R                  [.        5      XS)    R                  [.        5      :H  5      (       d  [#        S5      eUc'  Uc$  [        R                  " U R0                  [        S9nOUc  UnO}[        U[        R                  5      (       a>  UR                  [        R                  :X  a   Ub  X-  nO8U(       a  UR                  5       nO [        R2                  " U[        S9nUb  X-  nU R0                  UR0                  :w  a  [        S5      eX4$ )z
Coerce the input values array to numpy arrays with a mask.

Parameters
----------
values : 1D list-like
mask : bool 1D array, optional
copy : bool, default False
    if True, copy the input

Returns
-------
tuple of (values, mask)
Nz'cannot pass mask for BooleanArray inputiufcbr?   zNeed to pass bool-like valuesTskipna)floatingintegerzmixed-integer-float)r   rM   npt.NDArray[np.bool_]z&values.shape and mask.shape must match)rG   r/   
ValueError_data_maskcopyr   ndarrayr+   r   r'   r   rR   rI   r*   astypeallrF   asarrayobjectr   infer_dtyper   floatshaperT   )valuesrV   rt   mask_valuesvalues_boolvalues_objectinferred_dtypeinteger_likes           r    coerce_to_arrayr      s   " &,''FGG||V\\[[]F99;D|K&"**%%&,,"((*B[[]F	FBJJ	'	'FLL,=,=,H6lhhs6{$7$*<$8$?$?$EL!vv%,,V\\:f\>RR
 
 ;<<

68tDE!5!DD;<< 2D4GH#f+T2,\:AA$G| *FF|$++E2 .55e<= 
 ;<<|+xxD1	dBJJ''DJJ"((,B&)99;D88D-D&)||tzz!ABB<r#   c                  V  ^  \ rS rSrSrSrSrSr1 Skr1 Skr	\
SU 4S jj5       r S       SU 4S jjjr\SS	 j5       r\
S
SS
S
S.           SS jj5       r\R"                  \R&                  \\R*                  4r\
SS.     SS jj5       rS rSS.     SS jjrSrU =r$ )r/      a  
Array of boolean (True/False) data with missing values.

This is a pandas Extension array for boolean data, under the hood
represented by 2 numpy arrays: a boolean array with the data and
a boolean array with the mask (True indicating missing).

BooleanArray implements Kleene logic (sometimes called three-value
logic) for logical operations. See :ref:`boolean.kleene` for more.

To construct an BooleanArray from generic array-like input, use
:func:`pandas.array` specifying ``dtype="boolean"`` (see examples
below).

.. warning::

   BooleanArray is considered experimental. The implementation and
   parts of the API may change without warning.

Parameters
----------
values : numpy.ndarray
    A 1-d boolean-dtype array with the data.
mask : numpy.ndarray
    A 1-d boolean-dtype array indicating missing values (True
    indicates missing).
copy : bool, default False
    Whether to copy the `values` and `mask` arrays.

Attributes
----------
None

Methods
-------
None

Returns
-------
BooleanArray

Examples
--------
Create an BooleanArray with :func:`pandas.array`:

>>> pd.array([True, False, None], dtype="boolean")
<BooleanArray>
[True, False, <NA>]
Length: 3, dtype: boolean
FT>   1TRUETruetrue1.0>   0FALSEFalsefalse0.0c                D   > [         TU ]  X5      n[        5       Ul        U$ r   )super_simple_newr   _dtype)r0   r}   rV   result	__class__s       r    r   BooleanArray._simple_new-  s     $V2$r#   c                   > [        U[        R                  5      (       a  UR                  [        R                  :X  d  [        S5      e[        5       U l        [        TU ]%  XUS9  g )NzIvalues should be boolean numpy array. Use the 'pd.array' function insteadrt   )
rG   r   ru   r+   r   rF   r   r   r   __init__)r   r}   rV   rt   r   s       r    r   BooleanArray.__init__3  sT     62::..6<<2883K2  #nD1r#   c                    U R                   $ r   r   r   s    r    r+   BooleanArray.dtype>  s    {{r#   N)r+   rt   true_valuesfalse_valuesc               F  ^	^
 U R                   R                  U=(       d    / 5      m
U R                  R                  U=(       d    / 5      m	SU	U
4S jjn[        R                  " U[
        S9n[        U5      n[        [        XgU)    5      5      Xx) '   U R                  XrUS9$ )Nc                <   > U T;   a  gU T;   a  g[        U  S35      e)NTFz cannot be cast to bool)rq   )sfalse_values_uniontrue_values_unions    r    
map_string:BooleanArray._from_sequence_of_strings.<locals>.map_stringO  s.    %%(( A3&=!>??r#   r?   )r+   rt   r`   )
_TRUE_VALUESunion_FALSE_VALUESr   rT   ry   r   listmap_from_sequence)r0   stringsr+   rt   r   r   r   scalarsrV   r   r   s            @@r    _from_sequence_of_strings&BooleanArray._from_sequence_of_stringsB  s      ,,22;3D"E ..44\5GRH	@ 	@ ((7&1G}c*ten=>!!'T!BBr#   r   c               2    U(       a  US:X  d   e[        XS9$ )Nr   r   )r   )r0   valuer+   rt   s       r    _coerce_to_arrayBooleanArray._coerce_to_array^  s      I%%%u00r#   c                $   UR                   S;   d   e[        R                  " U5      nS n[        U[        5      (       a  UR
                  UR                  pAO|[        U5      (       a=  [        R                  " USS9nUR                  S:  a  [        S5      e[        USS9u  pO/[        U[        R                  5      (       a  UR                  5       nU(       aP  U[        R                   La=  [        R"                  " U5      (       d"  [%        S['        U5      R                    S	35      eU(       d#  [)        U 5      [)        U5      :w  a  [+        S
5      eUR                   S;   a/  [,        R.                  " U R
                  XR                  U5      u  pTOmUR                   S;   a/  [,        R0                  " U R
                  XR                  U5      u  pTO.[,        R2                  " U R
                  XR                  U5      u  pTU R5                  XT5      $ )N>   or_xorand_ror_rxorrand_r*   r?   r@   z(can only perform ops with 1-d structuresFr   z+'other' should be pandas.NA or a bool. Got z	 instead.zLengths must match>   r   r   >   r   r   )ra   r   	is_scalarrG   r/   rr   rs   r	   r   rx   ndimNotImplementedErrorr   r   item
libmissingNAis_boolrF   r!   rI   rq   r   	kleene_or
kleene_and
kleene_xor_maybe_mask_result)r   otheropother_is_scalarrV   r   s         r    _logical_methodBooleanArray._logical_methodf  s   {{MMMM--.e\**++u{{4%  JJuF3EzzA~)*TUU)%e<KE4rxx((JJLEuJMM9#++eBTBTE{++,I7 
 3t9E
#:122;;/)==UJJMLFD[[-->>$**eZZNLFD >>$**eZZNLF &&v44r#   rl   c                  U R                   nU R                  nUS;   a.  [        [        U5      nU" XE4SU0UD6u  pEU R	                  XE5      $ SSKJn  U" UR                  [        5      U5      R                  " U4SU0UD6$ )N)cummincummaxrm   r   )IntegerArray)
rr   rs   getattrr   r   pandas.core.arraysr   rv   int_accumulate)r   r   rm   kwargsrW   rV   r   r   s           r    r   BooleanArray._accumulate  s     zzzz''-t4BD@v@@JD##D//7C 0$7CC#'- r#   r   )r}   
np.ndarrayrV   rp   r^   r   )F)r}   r   rV   r   rt   r*   r^   None)r^   r   )r   z	list[str]r+   zDtype | Nonert   r*   r   list[str] | Noner   r   r^   r/   )r+   r   rt   r*   r^   tuple[np.ndarray, np.ndarray])r   r_   rm   r*   r^   r   )ra   rb   rc   rd   re   _internal_fill_value_truthy_value_falsey_valuer   r   rh   r   r   rg   r+   r   r   ru   numbersNumberr*   r   _HANDLED_TYPESr   r   r   ri   __classcell__)r   s   @r    r/   r/      sX   1h ! MM7L;M  BG	2 	2(2	2:>	2		2 	2   
 #(,)-CC 	C
 C &C 'C 
C C2 jj'..$AN5:1&1.21	&1 1!5H ,0$(	 r#   r/   )NF)rt   r*   r^   r   )$
__future__r   r   typingr   r   r   numpyr   pandas._libsr   r   r   pandas.core.dtypes.commonr	   pandas.core.dtypes.dtypesr
   pandas.core.dtypes.missingr   pandas.corer   pandas.core.array_algosr   pandas.core.arrays.maskedr   r   rC   pandas._typingr   r   r   r   r   r   r   r/   r&   r#   r    <module>r      s    "   
 3 > +  8
   l;? l; l;` %*T!T"Tnh? hr#   