
    Oh7              
       ,   d Z ddlZddlmZ ddlmZ ddlZddlZddlZ	ddl
Z
ddlZddlmZ ddlmZ ddlmZ  e
j&                  d       ddlZe
j,                  j/                  d      Ze
j2                  d	        Z e
j2                   e	j6                  d
dgd       ej8                  g dd       ej:                  dd       ej:                  dd      g ej<                  dd       ej<                  dd      gg      d        Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d  Z'd! Z(d" Z)d# Z*d$ Z+e
j,                  jY                  d% ejZ                  ddd
&       ejZ                  dd'd
d()       ej\                  g d*      g      d+        Z/d, Z0d- Z1y).z test orc compat     N)Decimal)BytesIO)read_orc)StringArrayzpyarrow.orcz=ignore:Passing a BlockManager to DataFrame:DeprecationWarningc                      | ddd      S )Niodataorc )datapaths    `/var/www/html/diagnosisapp-backend/venv/lib/python3.12/site-packages/pandas/tests/io/test_orc.pydirpathr      s    D&%((          uint64dtype)abr   category   )leftright   z
2022-01-03D)freqz
2022-01-04)paramsc                 D    t        j                  d| j                  i      S )Nunimpl)pd	DataFrameparam)requests    r   orc_writer_dtypes_not_supportedr%      s     <<7==122r   c           	         g d}dddddddd	|rd
nd	g	}t        j                  t        j                  d            }t        ||      D ]  \  }}t        j                  |      ||<     |j
                  j                  d
      |_        t        j                  j                  | d      }t        ||      }t        j                  ||       y )N	boolean1byte1short1int1long1float1double1bytes1string1boolint8int16int32int64float32float64objectstrr   indexr   zTestOrcFile.emptyFile.orccolumns)r!   r"   
RangeIndexzipSeriesr=   astypeospathjoinr   tmassert_equal)	r   using_infer_stringr=   dtypesexpectedcolnamer   	inputfilegots	            r   test_orc_reader_emptyrM   -   s    
G 	#
F ||"--"23Hgv. 3IIE23''..u5HW&ABI
9g
.COOHc"r   c                    t        j                  ddgd      t        j                  ddgd      t        j                  dd	gd
      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      d	}t        j                  j	                  |      }t
        j                  j                  | d      }t        ||j                               }t        j                  ||       y )NFTr1   r   r   d   r2         r3      r4       r5         ?       @r6         .      r7       r   r8   hibyer'   zTestOrcFile.test1.orcr<   )nparrayr!   r"   	from_dictrB   rC   rD   r   keysrE   rF   r   r	   rI   rK   rL   s        r   test_orc_reader_basicr`   O   s    HHeT]&91c(&1((D$<w7%w7.0CDGT((C:Y788UDM;((3S9J88T5M:
D ||%%d+HW&=>I
9diik
2COOHc"r   c                    dt        j                  t        d      t        d      t        d      t        d      t        d      t        d      t        d      t        d	      t        d
      t        d      g
d      i}t        j                  j                  |      }t        j                  j                  | d      }t        |      j                  d d }t        j                  ||       y )N_col0z-1000.50000z
-999.60000z
-998.70000z
-997.80000z
-996.90000z
-995.10000z
-994.11000z
-993.12000z
-992.13000z
-991.14000r8   r   zTestOrcFile.decimal.orc
   )r[   r\   r   r!   r"   r]   rB   rC   rD   r   ilocrE   rF   r_   s        r   test_orc_reader_decimalre   c   s     	&%%%%%%%%% 
D" ||%%d+HW&?@I
9

"
"3B
'COOHc"r   c                    t        j                  g dd      t        j                  t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      g
d      d}t        j
                  j                  |      }t        j                  j                  | d	      }t        |      j                  d d
 }t        j                  ||       y )N)
z1900-05-05 12:34:56.100000z1900-05-05 12:34:56.100100z1900-05-05 12:34:56.100200z1900-05-05 12:34:56.100300z1900-05-05 12:34:56.100400z1900-05-05 12:34:56.100500z1900-05-05 12:34:56.100600z1900-05-05 12:34:56.100700z1900-05-05 12:34:56.100800z1900-05-05 12:34:56.100900datetime64[ns]r   il        r8   timedatezTestOrcFile.testDate1900.orcrc   r[   r\   datetimerl   r!   r"   r]   rB   rC   rD   r   rd   rE   rF   r_   s        r   test_orc_reader_date_lowro   ~   (    #
 dB+dB+dB+dB+dB+dB+dB+dB+dB+dB+ 
!D@ ||%%d+HW&DEI
9

"
"3B
'COOHc"r   c                    t        j                  g dd      t        j                  t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      t        j                  ddd      g
d      d}t        j
                  j                  |      }t        j                  j                  | d	      }t        |      j                  d d
 }t        j                  ||       y )N)
z2038-05-05 12:34:56.100000z2038-05-05 12:34:56.100100z2038-05-05 12:34:56.100200z2038-05-05 12:34:56.100300z2038-05-05 12:34:56.100400z2038-05-05 12:34:56.100500z2038-05-05 12:34:56.100600z2038-05-05 12:34:56.100700z2038-05-05 12:34:56.100800z2038-05-05 12:34:56.100900rg   r   i  rh   ri   r8   rj   zTestOrcFile.testDate2038.orcrc   rm   r_   s        r   test_orc_reader_date_highrr      rp   r   c                 D   t        j                  g dd      t        j                  g dd      d}t        j                  j	                  |      }t
        j                  j                  | d      }t        |      j                  d d }t        j                  ||       y )	N)
iEAںijFiA!{i~iY5B
irhi;Sinqi:i(r4   r   )
f50dcb8382fdaaa90758c69e8caf3fee97332bd634da12bea4396d67d89e8ad71007ee8c82066r8   )r+   r0   zTestOrcFile.testSnappy.orcrc   )r[   r\   r!   r"   r]   rB   rC   rD   r   rd   rE   rF   r_   s        r   !test_orc_reader_snappy_compressedr~      s     
 88 
!D@ ||%%d+HW&BCI
9

"
"3B
'COOHc"r   c                    t        j                  d       t        j                  ddgd      t        j                  ddgd      t        j                  d	d
gd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      d	}t        j
                  j                  |      }t        j                         5 }|j                  |       t        |      }t        j                  ||       d d d        y # 1 sw Y   y xY wNpyarrowFTr1   r   r   rO   r2   rP   rQ   r3   rR   r4   rS   r5   rT   rU   r6   rV   rW   r7   rX   r   r8   rY   rZ   r'   )pytestimportorskipr[   r\   r!   r"   r]   rE   ensure_cleanto_orcr   rF   )r   r	   rI   rC   rL   s        r   test_orc_roundtrip_filer      s    	" HHeT]&91c(&1((D$<w7%w7.0CDGT((C:Y788UDM;((3S9J88T5M:
D ||%%d+H		 'dtn
#&	' ' 's   $3E  E)c                     t        j                  d       t        j                  ddgd      t        j                  ddgd      t        j                  d	d
gd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      t        j                  ddgd      d	} t        j
                  j                  |       }|j                         }t        t        |            }t        j                  ||       y r   )r   r   r[   r\   r!   r"   r]   r   r   r   rE   rF   )r	   rI   bytesrL   s       r   test_orc_roundtrip_bytesior     s     	" HHeT]&91c(&1((D$<w7%w7.0CDGT((C:Y788UDM;((3S9J88T5M:
D ||%%d+HOOE
75>
"COOHc"r   c                     t        j                  d       d}t        j                  t        |      5  | j	                          d d d        y # 1 sw Y   y xY w)Nr   z6The dtype of one or more columns is not supported yet.match)r   r   raisesNotImplementedErrorr   )r%   msgs     r   $test_orc_writer_dtypes_not_supportedr   *  sG     	"
BC	*#	6 1'..01 1 1s   AAc                     t        j                  d       t        j                  t	        d      dt
        j                  dgg dg dt	        t        dd            t        j                  d	d
d      dt
        j                  dgg dg dt        j                  dd      t        j                  d      t        j                  t        j                  d      gd      }|j                         j                         }t        t        |      d      }t        j                  |j                   D ci c]:  }|t        j"                  j%                  t'        j(                  ||   d            < c}      }| rlt        j*                  t'        j,                               }|d   j/                  |      |d<   |d   j/                  |      |d<   |d   j/                  |      |d<   t1        j2                  ||       y c c}w )Nr   abcr   cr   Nr   )s   foos   barNr            @      @r7   r   rU         @TFTTFN20130101   )periods20130103)stringstring_with_nanstring_with_noner   intfloatfloat_with_nanr1   bool_with_narn   datetime_with_natdtype_backendT)from_pandasr   r   r   )r   r   r!   r"   listr[   nanrangearange
date_range	TimestampNaTcopyr   r   r   r=   arraysArrowExtensionArraypar\   
ArrowDtyper   rA   rE   assert_frame_equal)rG   df
bytes_dataresultcolrI   string_dtypes          r   test_orc_dtype_backend_pyarrowr   4  s   
	"	5k #RVVS1 0+a$YYsCy9"BFFC0'/j!<Z(Z("	

B( !!#Jgj)CF|| zz	
 ..rxx3T/RSS	
H  }}RYY[1%h/66|D&./@&A&H&H&V"#'/0B'C'J'J<'X#$&(+	
s   0?G;c                     t        j                  d       t        j                  t	        d      dt
        j                  dgg dt	        t        dd            t        j                  dt        j                  dgd	
      t        j                  t        j                  t        j                  t        j                  gd	
      t        j                  ddd
      dt
        j                  dgg dg dd
      } | j                         j                         }t        t        |      d      }t        j                  t        t        j                   g dt
        j"                  
            t        t        j                   dt        j                  dgt
        j"                  
            t        t        j                   dt        j                  dgt
        j"                  
            t        j                  g dd	
      t        j                  dt        j                  dgd	
      t        j                  t        j                  t        j                  t        j                  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
      d
      }t%        j&                  ||       y )Nr   r   r   r   r   r   r   r   Int64r   r   r   r7   rU   r   r   r   )
r   r   r   r   int_with_nanna_onlyr   r   r1   r   numpy_nullabler   )r   r   r   r   r   r   )r   g      @g      @Float64booleanTF)r   r   r!   r"   r   r[   r   r   r@   NAr   r   r   r   r   r   r\   object_rE   r   )r   r   r   rI   s       r   %test_orc_dtype_backend_numpy_nullabler   ^  s   
	"	5k #RVVS1 0a$IIq"%%m7Cyy"%%!6gFYYsCy9"BFFC0'/	

B !!#Jgj)9IJF||!"((?"**"MN*#ruuc*"**=  !,#ruuc*"**=! 99Yg6IIq"%%m7Cyy"%%!6gFYYi@ iibeeS(9KII1CIItUBEE&:)L	
H& &(+r   c            	      V   t        j                  dt        t        dd            i      } t	        j
                  d      5 }| j                  |       t        j                  |      j                         }t        |      }d d d        t	        j                  |        y # 1 sw Y    xY w)Nr   r   r   tmp.orc)r!   r"   r   r   rE   r   r   pathlibPathas_urir   r   )rI   rC   urir   s       r   test_orc_uri_pathr     s    ||UDq!$567H		# tll4 '')# &(+	 s    A BB(r;   )startstopstepr   znon-default)r   r   r   namer   c                     t        j                  dg di|       }d}t        j                  t        |      5  |j                          d d d        y # 1 sw Y   y xY w)Nr   r   r:   z[orc does not support serializing a non-default index|orc does not serialize index meta-datar   )r!   r"   r   r   
ValueErrorr   )r;   r   r   s      r   test_to_orc_non_default_indexr     sQ     
sI&e	4B	1  
z	- 
		  s   AAc            	      L   d} t        j                  dt        t        dd            i      }t	        j
                  d      5 }|j                  |       t        j                  t        |       5  t        |d       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)	NzPdtype_backend numpy is invalid, only 'numpy_nullable' and 'pyarrow' are allowed.r   r   r   r   r   numpyr   )r!   r"   r   r   rE   r   r   r   r   r   r   )r   r   rC   s      r   test_invalid_dtype_backendr     s    	!  
ud5A;/0	1B		# 2t
		$]]:S1 	2T1	22 2	2 	22 2s$   -B/B=BB	BB#c           
         | dz  }t        j                  dddgi      }|j                  |       t        j                  dd      5  t	        |      }d d d        t        j                  dddgit        j
                  t        j                        t        j                  dgt        j
                  t        j                        	      
      }t        j                  |       y # 1 sw Y   xY w)Nztest_string_inference.pr   xy)r	   zfuture.infer_stringT)na_valuer   )r	   r   r=   )r!   r"   r   option_contextr   StringDtyper[   r   IndexrE   r   )tmp_pathrC   r   r   rI   s        r   test_string_inferencer     s    //D	C#s,	-BIIdO			0$	7  $ ||C:nnbff-#bnnbff&EFH
 &(+   s   C((C1)2__doc__rn   decimalr   r   r   rB   r   r   r[   r   pandasr!   r   pandas._testing_testingrE   pandas.core.arraysr   r   r   r   markfilterwarnings
pytestmarkfixturer   r\   r@   IntervalPeriodr%   rM   r`   re   ro   rr   r~   r   r   r   r   r   r   parametrizer>   r   r   r   r   r   r   r   <module>r      s       	       *   M " [[''C

 ) ) !R)		/4	!1	%{r{{'CD	<c	*IBIIl,MN	33#D#(#6&#R&#R&#R'2#01',T(,V, AAA.AAAMB	2,r   