
    d=/                        d dl Zd dlZd dlmZmZmZmZ d dlm	Z
 d dlmZ d Zd Zd Zd Zd Zd	 Zd
 Zej                            dg d          d             Zej                            dd d g          d             Zd Zej                            dd dfd dfg          d             Zej                            dg d          d             ZdS )    N)	DataFrameSeriesconcatmerge)	get_arrayc                    t          ddgdz  i          }t          ddgdz  i          }|                                }t          ||gd          }| rgt          j        t          |d          t          |d                    sJ t          j        t          |d          t          |d                    sJ nft          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    rJ d|j        d<   | rft          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    sJ d|j        d<   | r3t          j        t          |d          t          |d                    rJ t          j        ||           d S )	Nba      axisdr   r   r   r   )	r   copyr   npshares_memoryr   iloctmassert_frame_equal)using_copy_on_writedfdf2df_origresults        a/var/www/html/t/fyr/venv311/lib/python3.11/site-packages/pandas/tests/copy_view/test_functions.pytest_concat_framesr      s   	C##	$	$B
S3%!)$
%
%CggiiGRIA&&&F Q	&# 6 6	"c8J8JKKKKK	&# 6 6	#s8K8KLLLLLL#Ifc$:$:Ib#<N<NOOOOO#Ifc$:$:Ic3<O<OPPPPPFK M#Ifc$:$:Ib#<N<NOOOOO	&# 6 6	#s8K8KLLLLLFK Q#Ifc$:$:Ic3<O<OPPPPP"g&&&&&    c                    t          ddgdz  i          }t          ddgdz  i          }t          ||gd          }| rgt          j        t	          |d          t	          |d                    sJ t          j        t	          |d          t	          |d                    sJ nft          j        t	          |d          t	          |d                    rJ t          j        t	          |d          t	          |d                    rJ |                                }d|j        d<   | rft          j        t	          |d          t	          |d                    rJ t          j        t	          |d          t	          |d                    sJ d|j        d<   | r3t          j        t	          |d          t	          |d                    rJ t          j        ||           d S )Nr	   r
   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   )r   r   r   r   expecteds        r   !test_concat_frames_updating_inputr"   &   s   	C##	$	$B
S3%!)$
%
%CRIA&&&F Q	&# 6 6	"c8J8JKKKKK	&# 6 6	#s8K8KLLLLLL#Ifc$:$:Ib#<N<NOOOOO#Ifc$:$:Ic3<O<OPPPPP{{}}HBGDM M#Ifc$:$:Ib#<N<NOOOOO	&# 6 6	#s8K8KLLLLLCHTN Q#Ifc$:$:Ic3<O<OPPPPP&(+++++r   c                    t          ddgd          }t          ddgd          }|                                }|                                }t          ||gd          }| rUt          j        t          |d          |j                  sJ t          j        t          |d          |j                  sJ nTt          j        t          |d          |j                  rJ t          j        t          |d          |j                  rJ d	|j        d
<   | rTt          j        t          |d          |j                  rJ t          j        t          |d          |j                  sJ d|j        d<   | r*t          j        t          |d          |j                  rJ t          j	        ||           t          j	        ||           d S )Nr      r
   namer      r	   r   d   r     r   )
r   r   r   r   r   r   valuesr   r   assert_series_equal)r   serser2ser_orig	ser2_origr   s         r   test_concat_seriesr0   >   s   
!Qc
"
"
"C1a&s###DxxzzH		IS$Ka(((F I	&# 6 6
CCCCC	&# 6 6DDDDDD#Ifc$:$:CJGGGGG#Ifc$:$:DKHHHHHFK E#Ifc$:$:CJGGGGG	&# 6 6DDDDDFK I#Ifc$:$:DKHHHHH3)))4+++++r   c                     t          g dg dd          }t          dg di          }t          dg di          }t          t          ||gd          |gd          }|                                }| rt          j        t          |d	          t          |d	                    sJ t          j        t          |d          t          |d                    sJ t          j        t          |d          t          |d                    sJ nt          j        t          |d	          t          |d	                    rJ t          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    rJ d
|j        d<   | r3t          j        t          |d	          t          |d	                    rJ t          j        ||           d S )Nr   r$   r   )g?g?g333333?r
   r	   cr'         r   r   r   r
   r(   r   )	r   r   r   r   r   r   r   r   r   )r   df1r   df3r   r!   s         r   test_concat_frames_chainedr:   X   s   
)))///::
;
;C
S)))$
%
%C
S)))$
%
%CVS#JQ///5A>>>F{{}}H Q	&# 6 6	#s8K8KLLLLL	&# 6 6	#s8K8KLLLLL	&# 6 6	#s8K8KLLLLLL#Ifc$:$:Ic3<O<OPPPPP#Ifc$:$:Ic3<O<OPPPPP#Ifc$:$:Ic3<O<OPPPPPCHTN Q#Ifc$:$:Ic3<O<OPPPPP&(+++++r   c                    t          g dd          }t          g dd          }t          g dd          }t          t          ||gd          |gd          }|                                }| rt          j        t          |d          t          |d                    sJ t          j        t          |d          t          |d                    sJ t          j        t          |d          t          |d                    sJ nt          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    rJ d	|j        d
<   | r3t          j        t          |d          t          |d                    rJ t          j        ||           d S )Nr2   r
   r%   r5   r4   r   r   r   r(   r   )	r   r   r   r   r   r   r   r   r   )r   ser1r-   ser3r   r!   s         r   test_concat_series_chainedr>   o   s   )))#&&&D)))#&&&D)))#&&&DVT4Lq11148qAAAF{{}}H R	&# 6 6	$8L8LMMMMM	&# 6 6	$8L8LMMMMM	&# 6 6	$8L8LMMMMMM#Ifc$:$:IdC<P<PQQQQQ#Ifc$:$:IdC<P<PQQQQQ#Ifc$:$:IdC<P<PQQQQQDIaL R#Ifc$:$:IdC<P<PQQQQQ&(+++++r   c                    t          ddgd          }t          ddgd          }t          ddgddgd          }t          ||gd	          }| rgt          j        t          |d          t          |d                    sJ t          j        t          |d          t          |d                    sJ nft          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    rJ d
|j        d<   | rft          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    sJ t          j        ||           d|j        d<   | r3t          j        t          |d          t          |d                    rJ t          j        ||           d S )Nr   r$   r
   r%   r   r'   r	   r3   r   r(   r   r)   )	r   r   r   r   r   r   r   r   r   )r   r,   r-   r!   r   s        r   !test_concat_series_updating_inputr@      s   
!Qc
"
"
"C1a&s###D1vQF3344HS$Ka(((F R	&# 6 6	#s8K8KLLLLL	&# 6 6	$8L8LMMMMMM#Ifc$:$:Ic3<O<OPPPPP#Ifc$:$:IdC<P<PQQQQQCHQK N#Ifc$:$:Ic3<O<OPPPPP	&# 6 6	$8L8LMMMMM&(+++DIaL R#Ifc$:$:IdC<P<PQQQQQ&(+++++r   c                 2   t          g ddd          }t          g dd          }t          ||gd          }|                                }| rt	          j        t          |d          t          |d                    sJ t	          j        t          |d	          t          |d	                    sJ t	          j        t          |d          t          |d                    sJ nt	          j        t          |d          t          |d                    rJ t	          j        t          |d	          t          |d	                    rJ t	          j        t          |d          t          |d                    rJ d
|j        d<   | r3t	          j        t          |d          t          |d                    rJ d
|j        d<   | r3t	          j        t          |d          t          |d                    rJ t          j	        ||           d S )Nr2   r   )r
   r4   r5   r   r%   r   r
   r4   r(   r   r   )
r   r   r   r   r   r   r   r   r   r   )r   r   r,   r   r!   s        r   test_concat_mixed_series_framerB      s	   	++	,	,B

%
%
%CRIA&&&F{{}}H Q	&# 6 6	"c8J8JKKKKK	&# 6 6	"c8J8JKKKKK	&# 6 6	#s8K8KLLLLLL#Ifc$:$:Ib#<N<NOOOOO#Ifc$:$:Ib#<N<NOOOOO#Ifc$:$:Ic3<O<OPPPPPCHQK Q#Ifc$:$:Ic3<O<OPPPPPBGDM P#Ifc$:$:Ib#<N<NOOOOO&(+++++r   r   )TNFc                 "   t          dddgi          }t          dddgi          }t          ||gd|          }| s|du rht          j        t	          |d          t	          |d                    sJ t          j        t	          |d          t	          |d                    sJ d S t          j        t	          |d          t	          |d                    rJ t          j        t	          |d          t	          |d                    rJ d S )	Nr
   r   r$   r	   g      ?g      @)r   r   F)r   r   r   r   r   r   r   r   r   r   s        r   test_concat_copy_keywordrE      s   	C!Q=	!	!B
S3*%
&
&CRIAD111F Qdemm	"c 2 2Ifc4J4JKKKKK	#s 3 3Yvs5K5KLLLLLLL#Ib#$6$6	&#8N8NOOOOO#Ic3$7$7639O9OPPPPPPPr   funcc                      | j         |fi |S Nr   r8   r   kwargss      r   <lambda>rL      s    939S#;#;F#;#; r   c                     t          | |fi |S rH   rI   rJ   s      r   rL   rL      s    5c#<#<V#<#< r   c                    t          g dg dd          }t          g dg dd          }|                                }|                                } |||d          }| rt          j        t	          |d          t	          |d                    sJ t          j        t	          |d	          t	          |d	                    sJ t          j        t	          |d          t	          |d                    sJ t          j        t	          |d          t	          |d                    rJ nft          j        t	          |d          t	          |d                    rJ t          j        t	          |d	          t	          |d	                    rJ d
|j        d<   | rft          j        t	          |d          t	          |d                    rJ t          j        t	          |d	          t	          |d	                    sJ d
|j        d<   | r3t          j        t	          |d	          t	          |d	                    rJ t          j        ||           t          j        ||           d S )Nr
   r	   r4   r2   keyr
   r5   rQ   r	   rQ   )onr
   r	   r   r   r   r$   )r   r   r   r   r   r   r   r   )r   rF   r8   r   df1_origdf2_origr   s          r   test_merge_on_keyrW      se    OOO)))<<
=
=C
OOO)))<<
=
=CxxzzHxxzzHT#su%%%F Q	&# 6 6	#s8K8KLLLLL	&# 6 6	#s8K8KLLLLL	&% 8 8)C:O:OPPPPP#Ife$<$<iU>S>STTTTTT#Ifc$:$:Ic3<O<OPPPPP#Ifc$:$:Ic3<O<OPPPPPFK M#Ifc$:$:Ic3<O<OPPPPP	&# 6 6	#s8K8KLLLLLFK Q#Ifc$:$:Ic3<O<OPPPPP#x(((#x(((((r   c                    t          dg di          }t          dg di          }|                                }|                                }t          ||dd          }| rgt          j        t          |d          t          |d                    sJ t          j        t          |d          t          |d                    sJ nft          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    rJ d|j        d<   | rft          j        t          |d          t          |d                    rJ t          j        t          |d          t          |d                    sJ d|j        d	<   | r3t          j        t          |d          t          |d                    rJ t          j        ||           t          j        ||           d S )
Nr
   r2   r	   r5   T)
left_indexright_indexr   r   r   )	r   r   r   r   r   r   r   r   r   )r   r8   r   rU   rV   r   s         r   test_merge_on_indexr[      s   
S)))$
%
%C
S)))$
%
%CxxzzHxxzzH3$???F Q	&# 6 6	#s8K8KLLLLL	&# 6 6	#s8K8KLLLLLL#Ifc$:$:Ic3<O<OPPPPP#Ifc$:$:Ic3<O<OPPPPPFK M#Ifc$:$:Ic3<O<OPPPPP	&# 6 6	#s8K8KLLLLLFK Q#Ifc$:$:Ic3<O<OPPPPP#x(((#x(((((r   z	func, howc                 "    t          || fddi|S NrS   rQ   rI   rJ   s      r   rL   rL   	      E#s$G$Gu$G$G$G r   rightc                 "    t          | |fddi|S r]   rI   rJ   s      r   rL   rL   
  r^   r   leftc                    t          g dg dd          }t          ddgddgd          }|                                }|                                } ||||	          }| rt          j        t	          |d          t	          |d                    sJ t          j        t	          |d          t	          |d                    rJ |j                            d
          sJ |j                            d          sJ t          j        t	          |d          t	          |d                    |dk    u sJ t          j        t	          |d          t	          |d                    rJ nft          j        t	          |d          t	          |d                    rJ t          j        t	          |d          t	          |d                    rJ |dk    rd|j        d<   n
d|j        d<   | r3t          j        t	          |d          t	          |d                    rJ t          j	        ||           t          j	        ||           d S )NrO   r2   rP   r
   r	   r'   r6   rR   )howr   r   rQ   ra   r   rT   )
r   r   r   r   r   _mgr_has_no_referencer   r   r   )r   rF   rc   r8   r   rU   rV   r   s           r   test_merge_on_key_enlarging_onerf     sZ    OOO)))<<
=
=C
S#JaV44
5
5CxxzzHxxzzHT#s$$$F Q	&# 6 6	#s8K8KLLLLL#Ifc$:$:Ic3<O<OPPPPPx))!,,,,,x))!,,,,,	&% 8 8)C:O:OPP6M
 
 
 
 #Ife$<$<iU>S>STTTTTT#Ifc$:$:Ic3<O<OPPPPP#Ifc$:$:Ic3<O<OPPPPP
f}}DD Q#Ifc$:$:Ic3<O<OPPPPP#x(((#x(((((r   c                 ,   t          dddgi          }t          dddgi          }|                    ||dd          }| s|d	u rht          j        t	          |d          t	          |d                    sJ t          j        t	          |d          t	          |d                    sJ d S t          j        t	          |d          t	          |d                    rJ t          j        t	          |d          t	          |d                    rJ d S )
Nr
   r   r$   r	   r   g      @T)r   rY   rZ   F)r   r   r   r   r   rD   s        r   test_merge_copy_keywordrh   ,  s   	C!Q=	!	!B
S1c(O
$
$CXXc4XHHF Qdemm	"c 2 2Ifc4J4JKKKKK	#s 3 3Yvs5K5KLLLLLLL#Ib#$6$6	&#8N8NOOOOO#Ic3$7$7639O9OPPPPPPPr   )numpyr   pytestpandasr   r   r   r   pandas._testing_testingr   pandas.tests.copy_view.utilr   r   r"   r0   r:   r>   r@   rB   markparametrizerE   rW   r[   rf   rh    r   r   <module>rr      s                         1 1 1 1 1 1' ' '0, , ,0, , ,4, , ,., , ,., , ,2, , ,2 !4!4!455Q Q 65Q 
;;<< ) ) ):) ) )6 	G	GQ	G	GP ) ) )> !4!4!455Q Q 65Q Q Qr   