
    bMh'                         d Z ddlZddlZddlmZmZ ddlZddl	m
Z ddlmZmZ ej                            d          Z ej        d          Zej        j         G d d                      ZdS )	z test feather-format compat     N)pa_version_under18p0pa_version_under19p0)read_feather
to_featherz=ignore:Passing a BlockManager to DataFrame:DeprecationWarningpyarrowc                      e Zd Zd Zd Zdi fdZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zej        j        ej        j        d                         Zd Zd Zd Zd Zej                            ed          d             ZdS )TestFeatherc                     t          j        ||          5  t          j                    5 }t	          ||           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nmatch)pytestraisestmensure_cleanr   )selfdfexcerr_msgpaths        \/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pandas/tests/io/test_feather.pycheck_error_on_writez TestFeather.check_error_on_write   s     ]3g... 	% 	%"" %d2t$$$% % % % % % % % % % % % % % %	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s3   A AA A	A A	A  A$'A$c                     t          j        t                    5  t          j                    5 }t	          ||           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S N)r   external_error_raised	Exceptionr   r   )r   r   r   s      r   check_external_error_on_writez)TestFeather.check_external_error_on_write!   s     %i00 	% 	%"" %d2t$$$% % % % % % % % % % % % % % %	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s3   A#AA#A	A#A	A##A'*A'Nc                     ||                                 }t          j                    5 }t          ||fi | t	          |fi |}t          j        ||           d d d            d S # 1 swxY w Y   d S r   )copyr   r   r   r   assert_frame_equal)r   r   expectedwrite_kwargsread_kwargsr   results          r   check_round_tripzTestFeather.check_round_trip)   s    wwyyH_ 	4$r400<000!$66+66F!&(333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4s   1A((A,/A,c                     d}t          j        g d          ddt          j        d          t          j        g d          fD ]}|                     |t          |           d S )Nz'feather only support IO with DataFrames         r'   foo20130101)pdSeries	Timestampnparrayr   
ValueError)r   msgobjs      r   
test_errorzTestFeather.test_error4   st    7Iiii  L$$HYYY
 	< 	<C %%c:s;;;;	< 	<    c                 b   t          j        t          d          t          t          dd                    t	          j        dd                              d          t	          j        ddd	
          dt          j        dgg ddt          j        dgt          j        t          d                    t          j	        t          t          j
        dd                    d           t          j	        t          t          j
        ddd                    d           t          j        d          t           j        t          j        d          gt          j	        t          t          j
        ddd                    d           d          }t          j        ddd          |d<   t          j        dd          |d<   t          j        ddd          |d<   |j        j        j        j        dk    sJ |                                }d |j        d <   |                     ||!           d S )"Nabcr'      r)      u1g      @g      @float64dtypeg      ?TFTTFr+   )periods)freqz
US/Eastern)r?   tz20130103ns)r?   r@   )stringintuintfloatfloat_with_nullboolbool_with_nullcatdtdttzdt_with_nulldtns2013M)r@   r?   r?   z1 day
timedeltasr   	intervals)r'   rJ   )r    )r,   	DataFramelistranger/   arangeastypenanCategoricalDatetimeIndex
date_ranger.   NaTperiod_rangetimedelta_rangeinterval_rangerM   r=   rA   zoner   locr$   r   r   r    s      r   
test_basiczTestFeather.test_basic?   s   \u++E!QKK((	!Q..t4439===$'#3+++#'"7~d5kk22&z1===>>T   (z1NNNOO  
 L,,FL,,!
 (z14HHHIIPT  + 
 
6 S!DDD9-gqAAA<+Aq!44;w}$44447799,0()b844444r5   c                     t          j        t          j        d                              dd          t          d                                                    }|                     |           d S )N   r8   r)   aaacolumns)r,   rT   r/   rW   reshaperU   r   r   r   r   s     r   test_duplicate_columnsz"TestFeather.test_duplicate_columnse   s\     \")B--//155tE{{KKKPPRR**2.....r5   c                    t          j        t          d          t          t          dd                    t          d          t          t          dd                    d          }ddg}|                     |||         |	           d S )
Nr7   r'   r8   xyz   )col1col2col3col4rp   rr   )r    ri   )r,   rT   rU   rV   r$   )r   r   ri   s      r   test_read_columnszTestFeather.test_read_columnsk   s    \UU1a[[))UU1a[[))	 
 
 6"b2g;HHHHHr5   c                     t          j        ddgddgddgd          }|dd	g         }|                     ||dd	g
           d S )Nr'   r(   xyTF)ABCry   rx   rh   )r,   rT   r$   rc   s      r   !test_read_columns_different_orderz-TestFeather.test_read_columns_different_orderx   sY    \Ac3ZtUmLLMMsCj>b(S#J?????r5   c                 `    t          j        dg di          }|                     |           d S )Na)r}   r'          @)r,   rT   r   rk   s     r   test_unsupported_otherz"TestFeather.test_unsupported_other~   s4    \3.//**2.....r5   c                     t          j        dt          j        d          i          }|                     |d           |                     |d           d S )Nrx   i T)use_threadsF)r,   rT   r/   rW   r$   rk   s     r   test_rw_use_threadszTestFeather.test_rw_use_threads   sX    \3	& 1 1233bd333be44444r5   c           
         t          j        dt          j        d                              d          z  t          j        t          d                    t          j        d t          d          D                                                                 }t          j
        |j        t                    }t          j        ||           d S )N皙?x      r8   ABCDc                     g | ]}d | S zi- .0is     r   
<listcomp>z1TestFeather.test_path_pathlib.<locals>.<listcomp>       888HHH888r5   r   ri   index)r,   rT   r/   rW   rj   IndexrU   rV   reset_indexr   round_trip_pathlibr   r   r   r   r   r#   s      r   test_path_pathlibzTestFeather.test_path_pathlib   s    \")C..((111HT&\\**(88eBii88899
 
 
 +--	 	
 &r}lCC
b&)))))r5   c           
         t          j        dt          j        d                              d          z  t          j        t          d                    t          j        d t          d          D                                                                 }t          j
        |j        t                    }t          j        ||           d S )Nr   r   r   r   c                     g | ]}d | S r   r   r   s     r   r   z3TestFeather.test_path_localpath.<locals>.<listcomp>   r   r5   r   r   )r,   rT   r/   rW   rj   r   rU   rV   r   r   round_trip_localpathr   r   r   r   s      r   test_path_localpathzTestFeather.test_path_localpath   s    \")C..((111HT&\\**(88eBii88899
 
 
 +--	 	
 (EE
b&)))))r5   c           
      j   t          j        dt          j        d                              d          z  t          j        t          d                    t          j        d t          d          D                                                                 }| 	                    |dd	i
           d S )Nr   r   r   r   c                     g | ]}d | S r   r   r   s     r   r   z9TestFeather.test_passthrough_keywords.<locals>.<listcomp>   r   r5   r   r   versionr'   )r!   )
r,   rT   r/   rW   rj   r   rU   rV   r   r$   rk   s     r   test_passthrough_keywordsz%TestFeather.test_passthrough_keywords   s    \")C..((111HT&\\**(88eBii88899
 
 
 +--	 	
 	b	1~>>>>>r5   c                    t          |          }t          |d          5 }|                    |                                           t          |j                  }d d d            n# 1 swxY w Y   t          j        ||           d S )Nrb)content)r   openserve_contentreadurlr   r   )r   feather_file
httpserverr    fress         r   test_http_pathzTestFeather.test_http_path   s      --,%% 	/$$QVVXX$666z~..C	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	h,,,,,s   =A))A-0A-c                 
  	
 t          j        t          j        dt          j        dgd          t          j        g dd          t          j        dt          j        dgd          t          j        g d	d          g d
g dg dg dd          }t          j                    5 }t          ||           t          j        d|          5  t          ||          }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |dk    rdt          j        d          
|r't          j        
                                          }n;t          j        
                                          }nt          j        |          }t          j        t          j        dt          j        dgd          t          j        g dd          t          j        dt          j        dgd          t          j        g d	d          t          j        ddt           j        gd          t          j        g dd          t          j        g d|          t          j        g d|          d          	|dk    r-ddlm t          j        	
fd	j        D                       	|r=	j                            t          j        |t          j                            	_        t          j        |	           d S )Nr'   r)   Int64r<   r&         ?      @Float64)r   r~   r   )TFNr>   )r}   bc)r}   r   N)r}   r   r   der   ghzmode.string_storagedtype_backendr   TFbooleanr   )ArrowExtensionArrayc           	      ^    i | ])}|                      |         d                     *S )T)from_pandas)r0   )r   colr   r    pas     r   
<dictcomp>z?TestFeather.test_read_feather_dtype_backend.<locals>.<dictcomp>   sL        ,,RXXhsmQUX-V-VWW  r5   na_value)r,   rT   r-   r/   rY   r   r   r   option_contextr   r   importorskip
ArrowDtypelarge_stringrD   StringDtypeNApandas.arraysr   ri   rX   r   )r   string_storager   using_infer_stringr   r   r#   string_dtyper   r    r   s           @@@r   test_read_feather_dtype_backendz+TestFeather.test_read_feather_dtype_backend   s    \Y261~W===Yyyy888YRVS1CCCYi@@@(((((($__%%%	 	
 
 _ 	I$r4   "#8.II I I%d-HHHI I I I I I I I I I I I I I I	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I
 I%%$Y//B! :!}R__->->??!}RYY[[99>.99L<Y261~W===Yyyy888YRVS1CCCYi@@@YeRU39EEEY222)DDDYlCCCY///|DDD	 	
 
 I%%999999|     '/   H  	'/66~???   H 	fh/////s6   *&DC."D.C2	2D5C2	6DD	D	c                     t          j        dg dit          j        g dd                    }|                     |           d S )Nr}   r&   )r)   r8      test)name)r   )r,   rT   r   r$   rk   s     r   test_int_columns_and_indexz&TestFeather.test_int_columns_and_index   sL    \3			*"(99962R2R2RSSSb!!!!!r5   c           	      x   d}t          j        dt          t          dd                    i          }t	          j        d          5 }|                    |           t          j        t          |          5  t          |d           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )	NzPdtype_backend numpy is invalid, only 'numpy_nullable' and 'pyarrow' are allowed.rE   r'   r8   ztmp.featherr   numpyr   )r,   rT   rU   rV   r   r   r   r   r   r1   r   )r   r2   r   r   s       r   test_invalid_dtype_backendz&TestFeather.test_invalid_dtype_backend   s2   % 	 \5$uQ{{"3"3455_]++ 	:tMM$z555 : :T9999: : : : : : : : : : : : : : :	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:s6   1B/9BB/B	B/B	B//B36B3c                 :   |dz  }t          j        dddgi          }|                    |           t          j        dd          5  t	          |          }d d d            n# 1 swxY w Y   t          j        t          j                  }t          j        dddgit          j        t          j                  	          }t          j        dddgi|t          j        dgt          r	|st          n|
                    }t          j        ||           d S )Nztest_string_inference.pr}   rv   rw   )datafuture.infer_stringTr   r   r=   r<   )r   r=   ri   )r,   rT   r   r   r   r   r/   rY   r   r   objectr   r   )r   tmp_pathr   r   r   r#   r=   r    s           r   test_string_inferencez!TestFeather.test_string_inference   si   33\c3Z0111
d4d;; 	( 	(!$''F	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(///<Sz""."&*I*I*I
 
 
 <Sz"H'0Bff	  	
 	
 	
 	fh/////s   	A%%A),A)znot supported before 18.0)reasonc                    dd l }ddl m} |dz  }|                    d|                    g d|                                          i          }|                    ||           t          j        dd          5  t          |          }t          j	        dg dit          j
        t          j                  	          }d d d            n# 1 swxY w Y   t          j        ||           d S )
Nr   )featherzstring_view.parquetr}   )Nr   r   r   Tr   r   )r   r   tabler0   string_viewwrite_featherr,   r   r   rT   r   r/   rY   r   r   )r   r   r   r   r   r   r#   r    s           r   &test_string_inference_string_view_typez2TestFeather.test_string_inference_string_view_type  s?    	######//#rxx(8(8(8"..:J:JKKLMMeT***4d;; 	 	!$''F|+++,BNBF4S4S4S  H	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	fh/////s   :ACCC)__name__
__module____qualname__r   r   r$   r4   rd   rl   rt   r{   r   r   r   r   r   r   marknetwork
single_cpur   r   r   r   r   skipifr   r   r   r5   r   r	   r	      s       % % %% % % -1r 	4 	4 	4 	4	< 	< 	<$5 $5 $5L/ / /I I I@ @ @/ / /
5 5 5
* * ** * *? ? ? [[- -  -:0 :0 :0x" " "	: 	: 	:0 0 0. [,5PQQ0 0 RQ0 0 0r5   r	   )__doc__r   r/   r   pandas.compat.pyarrowr   r   pandasr,   pandas._testing_testingr   pandas.io.feather_formatr   r   r   filterwarnings
pytestmarkr   r   r   r	   r   r5   r   <module>r      s    " "            
           = = = = = = = =[''C 

 V## F0 F0 F0 F0 F0 F0 F0 F0 F0 F0r5   