Ë
    AúYj…  ã                  ó¬   — d Z ddlmZ ddlZddlZddlmZ ddlZddl	m
Z
 ddlZddlmZmZ ddlmZ erddlmZ  G d	„ d
e
«      Z G d„ de«      Zdd„Zy)zp
Test extension array for storing nested data in a pandas container.

The ListArray stores an ndarray of lists.
é    )ÚannotationsN)ÚTYPE_CHECKING)ÚExtensionDtype)Úis_object_dtypeÚis_string_dtype)ÚExtensionArray)Útype_tc                  ó4   — e Zd ZeZdZej                  Zdd„Z	y)Ú	ListDtypeÚlistc                ó   — t         S )zq
        Return the array type associated with this dtype.

        Returns
        -------
        type
        )Ú	ListArray©Úselfs    úl/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/pandas/tests/extension/list/array.pyÚconstruct_array_typezListDtype.construct_array_type!   s
   € ô Ðó    N)Úreturnztype_t[ListArray])
Ú__name__Ú
__module__Ú__qualname__r   ÚtypeÚnameÚnpÚnanÚna_valuer   © r   r   r   r      s   „ Ø€DØ€DØ�v‰v€Hôr   r   c                  óz   — e Zd Z e«       ZdZddd„Zedddœd„«       Zd„ Z	dd„Z
d	„ Zdd
„Zd„ Zdd„Zed„ «       Zy)r   iè  NFc                ó,  — t        |t        j                  «      st        d«      ‚|D ]c  }t        || j                  j
                  «      rŒ$t        j                  |«      rŒ:t        dt        | j                  j
                  «      z   «      ‚ || _	        y )Nz$Need to pass a numpy array as valueszAll values must be of type )
Ú
isinstancer   ÚndarrayÚ	TypeErrorÚdtyper   ÚpdÚisnaÚstrÚdata)r   Úvaluesr#   ÚcopyÚvals        r   Ú__init__zListArray.__init__0   sp   € Ü˜&¤"§*¡*Ô-ÜÐBÓCÐCØò 	VˆCÜ˜c 4§:¡:§?¡?Õ3¼B¿G¹GÀC½LÜÐ =ÄÀDÇJÁJÇOÁOÓ@TÑ TÓUÐUð	Vð ˆ�	r   ©r#   r)   c               ód   — t        j                  t        |«      t        ¬«      }||d d   | |«      S ©N©r#   )r   ÚemptyÚlenÚobject)ÚclsÚscalarsr#   r)   r'   s        r   Ú_from_sequencezListArray._from_sequence8   s)   € ä�x‰xœ˜G›¬FÔ3ˆØˆ‰QˆÙ�4‹yÐr   c                ó�   — t        |t        j                  «      r| j                  |   S  t	        | «      | j                  |   «      S ©N)r    ÚnumbersÚIntegralr'   r   )r   Úitems     r   Ú__getitem__zListArray.__getitem__>   s;   € Ü�dœG×,Ñ,Ô-Ø—9‘9˜T‘?Ð"ð ”4˜“:˜dŸi™i¨™oÓ.Ð.r   c                ó,   — t        | j                  «      S r7   )r1   r'   r   s    r   Ú__len__zListArray.__len__E   s   € Ü�4—9‘9‹~Ðr   c           	     ó¾   — t        j                  | j                  D �cg c]*  }t        |t        «       xr t        j
                  |«      ‘Œ, c}t        ¬«      S c c}w r.   )r   Úarrayr'   r    r   ÚisnanÚbool)r   Úxs     r   r%   zListArray.isnaH   sE   € Ü�x‰xØ>B¿i¹iÖH¸”˜AœtÓ$Ð$Ò4¬¯©°!«Ñ4ÒHÔPTô
ð 	
ùÚHs   ž/Ac                óÄ  — t        j                  |«      }d}|rV|€| j                  j                  }|dk  j	                  «       rt
        ‚	 |D �cg c]  }|dk7  r| j                  |   n|‘Œ }}n	 |D �cg c]  }| j                  |   ‘Œ }}| j                  |«      S c c}w # t        $ r}t        |«      |‚d }~ww xY wc c}w # t        $ r}t        |«      |‚d }~ww xY w)NzIIndex is out of bounds or cannot do a non-empty take from an empty array.éÿÿÿÿ)	r   Úasarrayr#   r   ÚanyÚ
ValueErrorr'   Ú
IndexErrorr5   )r   ÚindexerÚ
allow_fillÚ
fill_valueÚmsgÚlocÚoutputÚerrs           r   ÚtakezListArray.takeM   sò   € ô —*‘*˜WÓ%ˆàWð 	ñ ØÐ!Ø!ŸZ™Z×0Ñ0�
à˜"‘×!Ñ!Ô#Ü Ð ð/àKRöØDG c¨R¢i�D—I‘I˜c’N°ZÑ?ð�ñ ð/Ø4;Ö<¨S˜$Ÿ)™) C›.Ð<�Ð<ð ×"Ñ" 6Ó*Ð*ùòøô ò /Ü  “o¨3Ð.ûð/üò =øÜò /Ü  “o¨3Ð.ûð/úsT   ÁB# ÁBÁ-B# Á1C Á5C ÂC ÂB# Â#	B=Â,B8Â8B=Ã C Ã	CÃCÃCc                ó>   —  t        | «      | j                  d d  «      S r7   )r   r'   r   s    r   r)   zListArray.copyj   s   € ØŒt�D‹z˜$Ÿ)™)¡A˜,Ó'Ð'r   c                ó¶  — t        |t        | j                  «      «      r#|| j                  k(  r|r| j                  «       S | S t	        |«      rCt        |«      s8t        j                  | j                  D �cg c]  }t        |«      ‘Œ c}|¬«      S |s!t        j                  | j                  |¬«      S t        j                  | j                  ||¬«      S c c}w )Nr/   r,   )r    r   r#   r)   r   r   r   r?   r'   r&   rE   )r   r#   r)   rB   s       r   ÚastypezListArray.astypem   s›   € Ü�eœT $§*¡*Ó-Ô.°5¸D¿J¹JÒ3FÙØ—y‘y“{Ð"ØˆKÜ˜UÔ#¬O¸EÔ,Bä—8‘8¨T¯Y©YÖ7¨œS �VÒ7¸uÔEÐEÙÜ—:‘:˜dŸi™i¨uÔ5Ð5ä—8‘8˜DŸI™I¨U¸Ô>Ð>ùò	 8s   Á6Cc                óv   — t        j                  |D �cg c]  }|j                  ‘Œ c}«      } | |«      S c c}w r7   )r   Úconcatenater'   )r3   Ú	to_concatrB   r'   s       r   Ú_concat_same_typezListArray._concat_same_typez   s.   € ä�~‰~¨yÖ9¨!˜qŸv›vÒ9Ó:ˆÙ�4‹yÐùò :s   ”6)NF)r   ÚNone)r   Úint)FN)T)r   r   r   r   r#   Ú__array_priority__r+   Úclassmethodr5   r;   r=   r%   rP   r)   rS   rW   r   r   r   r   r   ,   s_   „ Ù‹K€EØÐôð Ø.2¸ó ó ðò
/óò
ó
+ò:(ó?ð ñó ñr   r   c                ó`  — t         j                  j                  d«      }t        j                  | t        ¬«      }t        | «      D �cg c]Q  }t        |j                  dd«      «      D �cg c]*  }|j                  t        t        j                  «      «      ‘Œ, c}‘ŒS c}|d d  |S c c}w c c}w )Né   r/   r   é
   )r   ÚrandomÚdefault_rngr0   r2   ÚrangeÚintegersÚchoicer   ÚstringÚascii_letters)ÚnÚrngr'   Ú_s       r   Ú	make_datari   €   s‰   € ä
�)‰)×
Ñ
 Ó
"€CÜ�8‰8�AœVÔ$€Dô �q“öàô :?¸s¿|¹|ÈAÈrÓ?RÓ9SÖT°Aˆ�‰”Dœ×-Ñ-Ó.Õ	/ÔTò€D‰€Gð €Kùò 	Uùòs   Á"B+Á*/B&
ÂB+Â&B+)rf   rY   )Ú__doc__Ú
__future__r   r8   rd   Útypingr   Únumpyr   Úpandas.core.dtypes.baser   Úpandasr$   Úpandas.api.typesr   r   Úpandas.core.arraysr   Úpandas._typingr	   r   r   ri   r   r   r   ú<module>rs      sQ   ðñõ #ã Û Ý  ã å 2ã ÷õ .áÝ%ô�ô ô Q�ô Qôhr   