
    bMh              
          d dl mZmZ d dlZd dlmc mZ d dlZ	d dl
mZ d Zd Zej        ej        j        d                         Zd Zd Zd Zd	 Zej                            d
d ej        d ej        d                    g          ej                            dddg          ej                            dddg          d                                     Zd ZdS )    )BytesIOStringIONc                 4   t          j        g dg dgddgg d          }t          j                    5 }|                    ||            t          j        |t          j        ||                      t          j        ||           5 }|                                	                    d          }t          |          }d d d            n# 1 swxY w Y   t          j        |t          j        |                     d d d            d S # 1 swxY w Y   d S )	N)g~Ϛ?g9DܜJ?g>D)?)g.4i(@g33333@g̤AAB)XYZ)indexcolumnscompressionutf8)pd	DataFrametmensure_cleanto_jsonassert_frame_equal	read_jsondecompress_filereaddecoder   )r   dfpathfhresultdatas         e/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pandas/tests/io/json/test_compression.pytest_compression_roundtripr       s   		'	'	')G)G)GHCj
 
 
B 
		 6d


4[
111
b",t"M"M"MNNN k22 	$bWWYY%%f--FF##D	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	b",t"4"45556 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6s6   AD7CDC	DC	*DDDc                      | dddd          }t          j        |          } | dddd          }t          j        |d          }t          j        ||           d S )Niojsonr   ztsframe_v012.jsonztsframe_v012.json.zipzipr   )r   r   r   r   )datapathuncompressed_pathuncompressed_dfcompressed_pathcompressed_dfs        r   test_read_zipped_jsonr*       sl     vv7JKKl#455OhtVV5LMMOLeDDDM/=99999    c                    t          j        t          d                    }t          j                    5 }|                    ||            t          |d          5 }|                    d|           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j        d|j         d| |          }t          j	        ||           d S )	N {"a": [1, 2, 3], "b": [4, 5, 6]}r   rbztest-1)KeyBodyzs3://z/test-1)r   storage_options)
r   r   r   r   r   r   open
put_objectnamer   )r   s3_public_buckets3sor   r   froundtripped_dfs          r   test_with_s3_urlr9   *   sX    
hABB	C	CB			 >d


4[
111$ 	>''H1'===	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>> > > > > > > > > > > > > > >
 l. %...  O
 "o.....s5   (BB5BB	BB		BBBc                 *   t          j                    5 }t          j        t	          d                    }|                    |dd|            t          j        |d|           }t          j        ||           d d d            d S # 1 swxY w Y   d S )Nr-   recordsTorientlinesr   )r>   r   )r   r   r   r   r   r   r   )r   r   r   r8   s       r   test_lines_with_compressionr?   =   s    			 3d\(#EFFGG


4	;
OOO,t4[QQQ
b/222	3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3s   A'BBBc                    t          j                    5 }t          j        t	          d                    }|                    |dd|            t          j        |dd|           5 }t          j        |          }d d d            n# 1 swxY w Y   t          j        ||           d d d            d S # 1 swxY w Y   d S )Nz,{"a": ["foo", "bar", "baz"], "b": [4, 5, 6]}r;   Tr<      )r>   	chunksizer   )r   r   r   r   r   r   concatr   )r   r   r   resr8   s        r   test_chunksize_with_compressionrE   E   s8   			 3d\(#QRRSS


4	;
OOO\{
 
 
 	- innO	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	b/2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3s6   AB5'B<B5B	B5B	B55B9<B9c                  8   t          j        t          d                    } t          j                    5 }d}t          j        t          |          5  |                     |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 )Nr-   *Unrecognized compression type: unsupportedmatchunsupportedr   )	r   r   r   r   r   pytestraises
ValueErrorr   )r   r   msgs      r   'test_write_unsupported_compression_typerO   Q   s   	hABB	C	CB			 8d:]:S111 	8 	8JJtJ777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	88 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8s5   BA7+B7A;	;B>A;	?BBBc                      t          j                    5 } d}t          j        t          |          5  t          j        | 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 )NrG   rH   rJ   r   )r   r   rK   rL   rM   r   r   )r   rN   s     r   &test_read_unsupported_compression_typerQ   Y   s    			 :d:]:S111 	: 	:L=9999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:: : : : : : : : : : : : : : : : : :s4   A-A	A-A	A-A	A--A14A1infer_stringFTpyarrow)marksto_infer
read_inferc                    t          j        d|          5  | }d}|||         z  }t          j        ddgi          }|rdn|}|rdn|}	t          j        |          5 }
|                    |
|           t          j        |
|	          }t          j        ||           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 )Nzfuture.infer_stringztest.r   rA   inferr   )r   option_contextr   r   r   r   r   r   )compression_onlyrV   rU   compression_to_extensionrR   r   filenamer   to_compressionread_compressionr   r   s               r   test_to_json_compressionr_   `   sj    
	0,	?	? . .& ,[99\3*%%$,=+&0A77k_X&& 	.$JJtJ888\$4DEEEF!&"---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.. . . . . . . . . . . . . . . . . .s7   ACAB, C,B0	0C3B0	4CCCc                     t          j        ddgi          }t                      5 }|                    ||            d d d            d S # 1 swxY w Y   d S )Nr   rA   r   )r   r   r   r   )r   expectedbuffers      r   test_to_json_compression_moderc   {   s    |S1#J''H	 :f[999: : : : : : : : : : : : : : : : : :s   AAA)r"   r   r   rK   pandas.util._test_decoratorsutil_test_decoratorstdpandasr   pandas._testing_testingr   r    r*   skip_if_not_us_localemark
single_cpur9   r?   rE   rO   rQ   parametrizeparam
skip_if_nor_   rc    r+   r   <module>rr      s         
  ) ) ) ) ) ) ) ) )          6 6 6$: : : / /  /"3 3 3	3 	3 	38 8 8: : : ULFL]R]95M5MNNNO  dE]33e}55. . 65 43 
.,: : : : :r+   