
    >ie9                        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	m
Z d dlmZ d dlmZmZ d dlmZ dZd Zd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"dS )    )annotations)dedentN)get_string_dtypepyarrow_strings_enabled)maybe_pluralizez<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
c                 4    t                      t          u rdndS )Nobjectstring)r   r	        @lib/python3.11/site-packages/dask/dataframe/tests/test_format.py_format_string_dtyper      s    '))V3388Ar       c                |    t                      rd|  dt          |dz   d           S d|  dt          |d           S )NzDask Name: to_pyarrow_stringz, r   zgraph layerzDask Name: from_pandas)r   r   )suffixlayerss     r   _format_footerr   #   sW       edfddQR
Ta8b8bdddVFVVofm.T.TVVVr   c                 H   t          j        dt          t          d                    i          } t	          j        | d          }||j        |j        fD ]L}t          |          j	        t          |          v sJ t          |j                  t          |          v sJ Md S )Nxd      )pd	DataFramelistrangeddfrom_pandasindexr   type__name__reprstrnpartitions)dfddfr   s      r   	test_reprr'   )   s    	sDs,,-	.	.B
.Q

C39ce$ - -Aww477****1=!!T!WW,,,,,- -r   c                 .   t          j        t          d          g dd          } t          j        | d          }t          |          }t          |          |k    sJ |j                            d          |_        t          |          |k    sJ d S )N   )abcde)r*   r+      r$   category)r   r   r   r   r   r"   r+   astype)r%   r&   s1s      r   test_repr_meta_mutationr4   2   s    	E!HH+D+D+DEE	F	FB
.
+
+
+C	cB99????ELL$$CE99??????r   c            	        t          j        d           t          j        g dt	          d          t          j        t	          d                    d          } t          j        | d          }t                      }t                      }t          d| d|           }t          |          |k    sJ t          |          |k    sJ t          d	| d
          }|                                |k    sJ d| d}d| d| d}|                                |k    sJ dt           | d| d}|                                |k    sJ d S )Njinja2r   r/   r      r)            ABCDEFGHAAABBBCCABCr   z        Dask DataFrame Structure:
                           A       B                C
        npartitions=3                                
        0              int64  z  category[known]
        3                ...     ...              ...
        6                ...     ...              ...
        7                ...     ...              ...
        z                           A       B                C
        npartitions=3                                
        0              int64  z  category[known]
        3                ...     ...              ...
        6                ...     ...              ...
        7                ...     ...              ...aN  <table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>A</th>
      <th>B</th>
      <th>C</th>
    </tr>
    <tr>
      <th>npartitions=3</th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>int64</td>
      <td>aY  </td>
      <td>category[known]</td>
    </tr>
    <tr>
      <th>3</th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
    <tr>
      <th>6</th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
    <tr>
      <th>7</th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
  </tbody>
</table>6<div><strong>Dask DataFrame Structure:</strong></div>

<div></div><<div><strong>Dask DataFrame Structure:</strong></div>
<div>

</div>
<div>)pytestimportorskipr   r   r   Categoricalr   r   r   r   r   r"   r#   	to_stringto_htmlstyle_repr_html_r%   r&   string_dtypefooterexp	exp_tables         r   test_dataframe_formatrS   <   s   
!!!	)))j!!Z 0 011	
 	

 
B .Q

C'))LF
	  ,		 	 
	 	
 
C 99s88s????
	9  ,	9 	9 	9 C ==??c!!!!)& ') ) )IV
   C ;;==C  	  C
 ??######r   c            	     ^   t          j        d           t          j        g dt	          d          t          j        t	          d                    dt	          d                    } t          j        | d          }t                      }t                      }t          d| d	|           }t          |          |k    sJ t          |          |k    sJ d
| d}d| d| d}|                                |k    sJ dt           | d| d}|                                |k    sJ d S )Nr6   r7   r<   r=   r>   r   r   z        Dask DataFrame Structure:
                           A       B                C
        npartitions=3                                
        A              int64  z  category[known]
        D                ...     ...              ...
        G                ...     ...              ...
        H                ...     ...              ...
        aN  <table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>A</th>
      <th>B</th>
      <th>C</th>
    </tr>
    <tr>
      <th>npartitions=3</th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>A</th>
      <td>int64</td>
      <td>aY  </td>
      <td>category[known]</td>
    </tr>
    <tr>
      <th>D</th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
    <tr>
      <th>G</th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
    <tr>
      <th>H</th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
  </tbody>
</table>rB   rC   rD   rE   rF   )rG   rH   r   r   r   rI   r   r   r   r   r   r"   r#   rK   rL   rM   rN   s         r    test_dataframe_format_with_indexrV      s   
!!!	)))j!!Z 0 011	
 	

 :
 
 
B .Q

C'))LF
	  ,		 	 
	 	
 
C 99s88s????)& ') ) )IV
   C ;;==C  	  C
 ??######r   c            	        t          j        d           t          j        g dt	          d          t          j        t	          d                    d          } t          j        | d          }|                                }|j	        rJ t                      }t                      }t          d| d|           }t          |          |k    sJ t          |          |k    sJ t          d	| d
          }|                                |k    sJ d| d}d| d| d}|                                |k    sJ dt"           | d| d}|                                |k    sJ d S )Nr6   r7   r<   r=   r>   r   z        Dask DataFrame Structure:
                           A       B                C
        npartitions=3                                
                       int64  z  category[known]
                         ...     ...              ...
                         ...     ...              ...
                         ...     ...              ...
        z                           A       B                C
        npartitions=3                                
                       int64  z  category[known]
                         ...     ...              ...
                         ...     ...              ...
                         ...     ...              ...aM  <table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>A</th>
      <th>B</th>
      <th>C</th>
    </tr>
    <tr>
      <th>npartitions=3</th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th></th>
      <td>int64</td>
      <td>aV  </td>
      <td>category[known]</td>
    </tr>
    <tr>
      <th></th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
    <tr>
      <th></th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
    <tr>
      <th></th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
  </tbody>
</table>rB   rC   rD   rE   rF   )rG   rH   r   r   r   rI   r   r   clear_divisionsknown_divisionsr   r   r   r"   r#   rJ   rK   rL   rM   rN   s         r   'test_dataframe_format_unknown_divisionsrZ      s   
!!!	)))j!!Z 0 011	
 	

 
B .Q

C




C""""'))LF
	  ,		 	 
	 	
 
C 99s88s????
	9  ,	9 	9 	9 C ==??c!!!!)& ') ) )IV
   C ;;==C  	  C
 ??######r   c            	        t          j        d           t          j        g ddz  t	          d          dz  t          j        t	          d          dz            d          } t                      }t                      }t          j	        | d          }t          d| d|           }t          |          |k    sJ t          |          |k    sJ t          d	| d
          }|                                |k    sJ d| d}d| d| d}|                                |k    sJ dt           | d| d}|                                |k    sJ d S )Nr6   r7   
   r<   r=   r>   z        Dask DataFrame Structure:
                            A       B                C
        npartitions=10                                
        0               int64  z  category[known]
        8                 ...     ...              ...
        ...               ...     ...              ...
        72                ...     ...              ...
        79                ...     ...              ...
        z                            A       B                C
        npartitions=10                                
        0               int64  z  category[known]
        8                 ...     ...              ...
        ...               ...     ...              ...
        72                ...     ...              ...
        79                ...     ...              ...aO  <table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>A</th>
      <th>B</th>
      <th>C</th>
    </tr>
    <tr>
      <th>npartitions=10</th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>int64</td>
      <td>a  </td>
      <td>category[known]</td>
    </tr>
    <tr>
      <th>8</th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
    <tr>
      <th>...</th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
    <tr>
      <th>72</th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
    <tr>
      <th>79</th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
  </tbody>
</table>rB   rC   rD   rE   rF   )rG   rH   r   r   r   rI   r   r   r   r   r   r"   r#   rJ   rK   rL   rM   )r%   rO   rP   r&   rQ   rR   s         r   test_dataframe_format_longr]   Q  s   
!!!	)))B.j!!B&Z 0 02 566	
 	

 
B ())LF
.R
 
 C
		 !-			 		 
		 		 C 99s88s????
	: !-	: 	: 	:	 	C ==??c!!!!/& '/ / /Ib
   C ;;==C  	  C
 ??######r   c                 N   t          j        g dt          d                    } t          j        | d          }t                      }t          d|           }t          |          |k    sJ t          |          |k    sJ t          d          }|	                                |k    sJ t          j        g dt          d          d          } t          j        | d          }t          d	|           }t          |          |k    sJ t          |          |k    sJ d S )
Nr7   r<   rU   r   z~    Dask Series Structure:
    npartitions=3
    A    int64
    D      ...
    G      ...
    H      ...
    dtype: int64
    zM    npartitions=3
    A    int64
    D      ...
    G      ...
    H      ...XXX)r   namez    Dask Series Structure:
    npartitions=3
    A    int64
    D      ...
    G      ...
    H      ...
    Name: XXX, dtype: int64
    
r   Seriesr   r   r   r   r   r"   r#   rJ   sdsrP   rQ   s       r   test_series_formatrf     s@   
	***$z2B2BCCCA	1		BF
	 	 	
 
C 88s????r77c>>>>
	 C <<>>S    
	***$z2B2BOOOA	1		B
	 	 	
 
C 88s????r77c>>>>>>r   c                 l   t          j        g ddz  t          d          dz            } t          j        | d          }t                      }t          d|           }t          |          |k    sJ t          |          |k    sJ t          d          }|	                                |k    sJ d S )N)
r   r/   r   r8   r)   r9   r:   r;   	   r\   r\   
ABCDEFGHIJrU   z        Dask Series Structure:
        npartitions=10
        A    int64
        B      ...
             ...  
        J      ...
        J      ...
        dtype: int64
        z]    npartitions=10
    A    int64
    B      ...
         ...  
    J      ...
    J      ...ra   rc   s       r   test_series_format_longrj     s    
	111B6d<>P>PSU>UVVVA	2		BF
		 
		 		 C 88s????r77c>>>>
	 C <<>>S      r   c                 Z   t          j        g dt          d                    } t          j        | d          }t                      }t          dd          }t          d| d| d	|           }t          |j	                  |k    sJ t          |j	                  |k    sJ t          j        g dt          j        g dd
                    } t          j        | d          }t          d          }t          |j	                  |k    sJ t          |j	                  |k    sJ d S )Nr7   r<   rU   r   z-indexr/   z5    Dask Index Structure:
    npartitions=3
    A    z<
    D       ...
    G       ...
    H       ...
    dtype: z
    YYY)r`   z    Dask Index Structure:
    npartitions=3
    1    category[known]
    4                ...
    7                ...
    8                ...
    Name: YYY, dtype: category
    Dask Name: from_pandas-index, 2 graph layers)r   rb   r   r   r   r   r   r   r"   r   r#   CategoricalIndex)rd   re   rO   rP   rQ   s        r   test_index_formatrn     s_   
	***$z2B2BCCCA	1		B'))LHa((F
	 	 	 	 	 	 	
 
C >>S    rx==C
	   !":":":GGG	 	 	A 
1		B
	4
 
C >>S    rx==Cr   c                    t          j        g d                              d          } t          j        | d          }|j                                        }d}t          |          |k    sJ d}t          |          |k    sJ d S )N)r*   r+   r,   r1   r   r0   zDask Series Structure:
npartitions=1
0    category[known]
2                ...
dtype: category
Dask Name: from_pandas, 1 graph layerzDask Series Structure:
npartitions=1
0    category[unknown]
2                  ...
dtype: category
Dask Name: from_pandas, 1 graph layer)r   rb   r2   r   r   cat
as_unknownr"   )rd   knownunknownrQ   s       r   test_categorical_formatrt   )  s    
	///""))*55AN1!,,,Ei""$$G	0  ;;#	0  ==Cr   c                     t          j        t          j        d                              dd          d          } t          j        | ddg          }t          |           d S )Nr\   r)   r/   )r)   r/   )chunksr*   )columns)da
from_arraynparangereshaper   from_dask_arrayr"   )arrframes     r   test_duplicate_columns_reprr   A  sV    
-	"--a33F
C
C
CCsS#J777EKKKKKr   c                    t          j        d           t          j                    } t	          j        | d          }d}t          |          |k    sJ d}d                    t          |          }|	                                |k    sJ d S )Nr6   r   r0   zaEmpty Dask DataFrame Structure:
Columns: []
Divisions: [, ]
Dask Name: from_pandas, 1 graph layera  <table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
    </tr>
    <tr>
      <th>npartitions=1</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th></th>
    </tr>
    <tr>
      <th></th>
    </tr>
  </tbody>
</table>z<div><strong>Dask DataFrame Structure:</strong></div>
<div>
{style}{exp_table}
</div>
<div>Dask Name: from_pandas, 1 graph layer</div>)rL   rR   )
rG   rH   r   r   r   r   r"   formatrL   rM   )r%   r&   rQ   rR   s       r   test_empty_reprr   G  s    
!!!	B
.
+
+
+C	0  99I$4 5;Fy 5; 5 5	  ??######r   )r   r   )#
__future__r   textwrapr   numpyrz   pandasr   rG   
dask.arrayarrayrx   dask.dataframe	dataframer   dask.dataframe.utilsr   r   
dask.utilsr   rL   r   r   r'   r4   rS   rV   rZ   r]   rf   rj   rn   rt   r   r   r   r   r   <module>r      s   " " " " " "                            J J J J J J J J & & & & & &	 B B BW W W W- - -  \$ \$ \$~Q$ Q$ Q$h_$ _$ _$Dc$ c$ c$L* * *Z! ! !<$  $  $ N     0  $$ $$ $$ $$ $$r   