a
    d                     @   s   d dl mZmZ d dlZd dlm  mZ d dlZ	d dl
mZ dd Zdd Zejejjdd Zd	d
 Zdd Zdd Zdd Zejdddgejdddgdd Zdd ZdS )    )BytesIOStringIONc              	   C   s   t jg dg dgddgg dd}t }|j|| d t|t j|| d t|| &}| 	d}t
|}W d    n1 s0    Y  t|t | W d    n1 s0    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_jsonZdecompress_filereaddecoder   )r   dfpathfhresultdata r   n/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/pandas/tests/io/json/test_compression.pytest_compression_roundtrip   s    
&r   c                 C   sD   | dddd}t |}| dddd}t j|dd}t|| d S )Niojsonr   ztsframe_v012.jsonztsframe_v012.json.zipzipr   )r   r   r   r   )datapathZuncompressed_pathZuncompressed_dfZcompressed_pathZcompressed_dfr   r   r   test_read_zipped_json    s
    
r#   c              	   C   s   t td}t V}|j|| d t|d}|jd|d W d    n1 sT0    Y  W d    n1 sr0    Y  t jd|j d| |d}t	|| d S )	N {"a": [1, 2, 3], "b": [4, 5, 6]}r   rbztest-1)ZKeyZBodyzs3://z/test-1)r   Zstorage_options)
r   r   r   r   r   r   openZ
put_objectnamer   )r   Zs3_public_bucketZs3sor   r   froundtripped_dfr   r   r   test_with_s3_url*   s    
Jr*   c                 C   sh   t  L}ttd}|j|dd| d tj|d| d}t || W d    n1 sZ0    Y  d S )Nr$   recordsTZorientlinesr   )r-   r   )r   r   r   r   r   r   r   )r   r   r   r)   r   r   r   test_lines_with_compression=   s
    
r.   c              	   C   s   t  x}ttd}|j|dd| d tj|dd| d}t|}W d    n1 s\0    Y  t || W d    n1 s0    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   resr)   r   r   r   test_chunksize_with_compressionE   s    
(r3   c               	   C   sz   t td} t P}d}tjt|d | j|dd W d    n1 sN0    Y  W d    n1 sl0    Y  d S )Nr$   *Unrecognized compression type: unsupportedmatchunsupportedr   )	r   r   r   r   r   pytestraises
ValueErrorr   )r   r   msgr   r   r   'test_write_unsupported_compression_typeQ   s
    
r<   c               	   C   sl   t  P} d}tjt|d tj| dd W d    n1 s@0    Y  W d    n1 s^0    Y  d S )Nr4   r5   r7   r   )r   r   r8   r9   r:   r   r   )r   r;   r   r   r   &test_read_unsupported_compression_typeY   s    
r=   to_inferTF
read_inferc                 C   s   | }d}||| 7 }t ddgi}|r,dn|}|r8dn|}t|8}	|j|	|d t j|	|d}
t|
| W d    n1 s0    Y  d S )Nztest.r   r/   Zinferr   )r   r   r   r   r   r   r   )Zcompression_onlyr?   r>   Zcompression_to_extensionr   filenamer   Zto_compressionZread_compressionr   r   r   r   r   test_to_json_compression`   s    rA   c                 C   sH   t ddgi}t }|j|| d W d    n1 s:0    Y  d S )Nr   r/   r   )r   r   r   r   )r   expectedbufferr   r   r   test_to_json_compression_modew   s    rD   )r   r   r   r8   Zpandas.util._test_decoratorsutilZ_test_decoratorstdZpandasr   Zpandas._testingZ_testingr   r   r#   Zskip_if_not_us_localemarkZ
single_cpur*   r.   r3   r<   r=   ZparametrizerA   rD   r   r   r   r   <module>   s"   
