
    d`                    (   d dl mZ d dl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Zd dlmZ d dlmZmZ  G d d          ZddZddZddZddZedd            Ze	j                            dg d          dd            ZddZdddZddZdS )    )annotationsN)dedent)defchararray)
formatting)requires_daskrequires_netCDF4c                      e Zd ZddZddZddZddZddZddZdd	Z	dd
Z
ddZddZddZddZd ZddZej                            d          dd            ZddZddZddZddZedd            ZdS )TestFormattingreturnNonec                <   dt          d          ft          dd           ffddt          d          fdt          dd           ffddt          d          fdt          dd           ffdt          d	          t          d           ft          d
d           t          d           ffddt          d	          t          d           fdt          d
d           t          d           ffddt          d	          t          d           fdt          d
d           t          d           ffddt          d          t          d           fdt          dd           t          d           ffdt          d	          t          d           t          d           ft          d
d           t          d           t          d           ffddt          d          t          d           fdt          dd           t          d           ffdt          d	          t          d           t          d           ft          d
d           t          d           t          d           ffg
}|D ]D\  }}}t          j        |dd          }||k    sJ t          j        |dd          }||k    sJ Ed S )N)   
   i)   r   r   )   r   )r      r   )   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r      )r   r   r   F)from_endT)slicer   _get_indexer_at_least_n_items)selfcasesshapestart_expectedend_expectedactuals         <lib/python3.11/site-packages/xarray/tests/test_formatting.py!test_get_indexer_at_least_n_itemsz0TestFormatting.test_get_indexer_at_least_n_items   sl   U2YYL5d#3#3"56q%))nr5d+;+;&<=q%))nr5d+;+;&<=eAhhd,uRd.LME!HHeDkk2Rr4%PT++4VWE!HHeDkk2Rr4%PT++4VWE"IIuT{{+U3%%uT{{3 q5;;d4r4%++uT{{;
 E!HHeDkk2Rr4%PT++4VWq5;;d4r4%++uT{{;%
0 49 	* 	*/E><=eRRWXXXF!V++++=eRRVWWWF6)))))		* 	*    c                p   t          j        d                              ddd          }dD ]@}t          j        ||          }|j        d |         }||k                                    sJ At          j        t          d          5  t          j        |d           d d d            d S # 1 swxY w Y   d S 	Nd   r   r   r   )r   r      r&      zat least one item)matchr   )
nparangereshaper   first_n_itemsflatallpytestraises
ValueErrorr   arraynr    expecteds        r!   test_first_n_itemsz!TestFormatting.test_first_n_items0   s    	#&&r1a00& 	. 	.A-eQ77Fz"1"~H&++------]:-ABBB 	/ 	/$UA...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   B++B/2B/c                r   t          j        d                              ddd          }dD ]A}t          j        ||          }|j        | d          }||k                                    sJ Bt          j        t          d          5  t          j
        |d           d d d            d S # 1 swxY w Y   d S r%   )r*   r+   r,   r   last_n_itemsr.   r/   r0   r1   r2   r-   r3   s        r!   test_last_n_itemsz TestFormatting.test_last_n_items:   s    	#&&r1a00& 	. 	.A,UA66Fz1"##H&++------]:-ABBB 	/ 	/$UA...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   	B,,B03B0c                    t          j        d          }d}t          j        dg          }|D ]1}t          j        |                    |                    }||k    sJ 2d S )Nr&   ))r   r   )r   r&   )r   r   r   r   c   )r*   r+   r4   r   	last_itemr,   )r   r4   r,   r6   rresults         r!   test_last_itemzTestFormatting.test_last_itemD   sl    	#48RD>> 	& 	&A)%--*:*:;;FX%%%%%	& 	&r#   c                   t          j        d          dft          j        d          dft          j        d          dft          j        d          dft          j        d          dft          j        d	          d
ft          j        d          dfddddt          j        d          dft          j        d          dft          j        d          dfg}|D ]!\  }}t          j        |          }||k    sJ "d S )Nz2000-01-01T12z2000-01-01T12:00:00z
2000-01-01NaTz10 days 1 hourz10 days 01:00:00z-3 daysz-3 days +00:00:00z3 hoursz0 days 03:00:00)fooz'foo')s   foozb'foo')r   1)g      ?z1.0g8EGr?z1.123g1Ղ-?z1.011gs~86@z22.22)	pd	Timestamp	Timedeltar*   float16float32float64r   format_itemr   r   itemr6   r    s        r!   test_format_itemzTestFormatting.test_format_itemN   s   \/**,AB\,''6\%  %(\*++-?@\)$$&9:\)$$&78\%  %(Z)Z	""G,Z	""G,
  $ 	& 	&ND(+D11Fv%%%%%	& 	&r#   c                   t          j        d          t          j        dd          z  dft          j        d          t          j        dd          z  dft          j        d          t          j        dd	          z  d
ft          j        g d          dft          j        g d          dfg ddfg}|D ]4\  }}d                    t          j        |                    }||k    sJ 5d S )Nr   r   Dz0 days 1 days 2 days 3 daysr   hz#00:00:00 03:00:00 06:00:00 09:00:00  msz100:00:00 00:00:00.500000 00:00:01 00:00:01.500000)rB   0s1srB   zNaT 00:00:00 00:00:01 NaT)z1 day 1 hourz1 dayz0 hoursz/1 days 01:00:00 1 days 00:00:00 0 days 00:00:00r   r   r   z1 2 3 )r*   r+   timedelta64rE   to_timedeltajoinr   format_itemsrL   s        r!   test_format_itemsz TestFormatting.test_format_itemsc   s
   Yq\\BN1c2224QR	!r~a5555
 	!r~c4888C _77788:UV D D DEEA YY 
" $ 	& 	&ND(XXj5d;;<<Fv%%%%%	& 	&r#   c                    t          j        t          j        d          d          }d}||k    sJ t          j        t          j        d          d          }d}||k    sJ t          j        t          j        d          d          }d}||k    sJ t          j        t          j        d          d          }d	}||k    sJ t          j        t          j        d          d
          }d}||k    sJ t          j        t          j        d          d          }d}||k    sJ t          j        t          j        d          d          }d}||k    sJ t          j        t          j        d          d          }d}||k    sJ t          j        t          j        d          d          }d}||k    sJ t          j        t          j        d          d          }d}||k    sJ t          j        t          j        d          d          }d}||k    sJ t          j        t          j        d          d          }d}||k    sJ t          j        t          j        d          d          }d}||k    sJ t          j        t          j        d          d          }d}||k    sJ d                    d  t          d          D                       g}t          j        t          j        |g          d!          }d"}||k    sJ d S )#Nr&   r   ...	   z0 ... 99r   z
0 1 ... 99r'   z0 1 ... 98 99   z0 1 2 ... 98 99g      Y@   z0.0 ... ...   z0.0 ... 99.0r   r   z0 1 2g      @z0.0 ... 3.0r    r   0z0 1r      z0 1 2 3z0 ... 4rW   c                    g | ]}d S )zhello world ).0_s     r!   
<listcomp>z9TestFormatting.test_format_array_flat.<locals>.<listcomp>   s    @@@m@@@r#      z'hello world hello...)r   format_array_flatr*   r+   rZ   rangeasarray)r   r    r6   long_strs       r!   test_format_array_flatz%TestFormatting.test_format_array_flaty   s   -binna@@6!!!!-binna@@6!!!!-binnbAA6!!!!-binnbAA"6!!!!-binnbAA$6!!!! -bi.>.>CC 6!!!!-bi.>.>CC!6!!!!-billA>>6!!!!-binnbAA 6!!!!-billA>>6!!!!-billA>>6!!!!-billA>>6!!!!-billA>>6!!!!-billA>>6!!!!HH@@U3ZZ@@@AAB-bj(.D.DbII*6!!!!!!r#   c                r    t          j        dd          dk    sJ t          j        dd          dk    sJ d S )N
abcdefghij   zabcde...   ßr   )r   pretty_printr   s    r!   test_pretty_printz TestFormatting.test_pretty_print   sD    &|Q77:EEEE&tQ//4777777r#   c                <    t          j        dd          dk    sJ d S )Nrt   r   )r   maybe_truncaterv   s    r!   test_maybe_truncatez"TestFormatting.test_maybe_truncate   s&    (r22d::::::r#   c                    d}t          j        t                    5  t          j        |           d d d            d S # 1 swxY w Y   d S )Nz2021-12-06 17:00:00 00)r0   r1   r2   r   format_timestamp)r   r6   s     r!   +test_format_timestamp_invalid_pandas_formatz:TestFormatting.test_format_timestamp_invalid_pandas_format   s    +]:&& 	2 	2'111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s   >AAc                    ddl m }  |ddd          }d}t          j        |          }||k    sJ  |ddd          }d}t          j        |          }||k    sJ d S )	Nr   )datetimei  rb   r   z
1300-12-01i  z
2300-12-01)r   r   r|   )r   r   dater6   r?   s        r!   #test_format_timestamp_out_of_boundsz2TestFormatting.test_format_timestamp_out_of_bounds   s    %%%%%%xb!$$,T22!!!!xb!$$,T22!!!!!!r#   c                .   t          j        dd          }t          j        dd          }t          j        dd          }t          j        dd          }|dk    sJ t          |          dk    sJ |                    d          sJ d	|vsJ d
|vsJ d S )NkeyzShort stringa  Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string Very long string z


z			z    key: Short stringP   r^   
	)r   summarize_attrlenendswith)r   shortlongnewlinestabss        r!   test_attribute_reprz"TestFormatting.test_attribute_repr   s    )%@@(0IJJ,UH==(99/////4yyB}}U#####8####4r#   c                   ddl m}  G d d|          }ddg} ||          }d}t          j        ||d          }||v sJ d|v sJ d	 |_        t          j        ||d          }||v sJ |                    d
          |v sJ d S )Nr   )Indexc                      e Zd Zd Zd ZdS )3TestFormatting.test_index_repr.<locals>.CustomIndexc                    || _         d S Nnames)r   r   s     r!   __init__z<TestFormatting.test_index_repr.<locals>.CustomIndex.__init__   s    "


r#   c                    d| j          dS )NzCustomIndex(coords=)r   rv   s    r!   __repr__z<TestFormatting.test_index_repr.<locals>.CustomIndex.__repr__   s    :TZ::::r#   N)__name__
__module____qualname__r   r   rg   r#   r!   CustomIndexr      s2        # # #; ; ; ; ;r#   r   xyr   )	col_widthc                >    dd                     | j                   dS )NzCustomIndex[z, ])rZ   r   )r   	max_widths     r!   <lambda>z0TestFormatting.test_index_repr.<locals>.<lambda>   s     $K499TZ3H3H$K$K$K r#   (   r   )xarray.core.indexesr   r   summarize_index_repr_inline_)r   r   r   coord_namesindexnamenormalinlines           r!   test_index_reprzTestFormatting.test_index_repr   s    ------	; 	; 	; 	; 	;% 	; 	; 	; CjK((+D%2FFFv~~~~&&&& LK 	! +D%2FFFv~~~~""R"00F::::::r#   c           
        t          j        t          j        g dg dgd          dt          j        ddgd          t          j        g dd          dd	d
d          }t          j        t          j        ddgd          dt          j        ddgd          dt          j        ddgd          fdddi          }t          j        dk    rdnd}t          d||fz            }t          j        ||d          }	 ||k    sJ n,# t          $ r ||
                    dd          k    sJ Y nw xY wt          j        dt          j        g dd          ddi          }t          j        dt          j        g dg dgd                    }t          d          }t          j        ||d          }	 ||k    sJ d S # t          $ r  ||
                    dd          k    sJ Y d S w xY w)NrV   r   r      int64dtyper   r   abU1mdescunitsdescription)dimscoordsattrsr   r   r   cr   labelr   kglittle<>a          Left and right DataArray objects are not identical
        Differing dimensions:
            (x: 2, y: 3) != (x: 2)
        Differing values:
        L
            array([[1, 2, 3],
                   [4, 5, 6]], dtype=int64)
        R
            array([1, 2], dtype=int64)
        Differing coordinates:
        L * x        (x) %cU1 'a' 'b'
        R * x        (x) %cU1 'a' 'c'
        Coordinates only on the left object:
          * y        (y) int64 1 2 3
        Coordinates only on the right object:
            label    (x) int64 1 2
        Differing attributes:
        L   units: m
        R   units: kg
        Attributes only on the left object:
            description: desc	identicalz, dtype=int64rc   titleztest Variablea          Left and right Variable objects are not equal
        Differing dimensions:
            (x: 3) != (x: 2, y: 3)
        Differing values:
        L
            array([1, 2, 3], dtype=int64)
        R
            array([[1, 2, 3],
                   [4, 5, 6]], dtype=int64)equals)xr	DataArrayr*   r4   sys	byteorderr   r   diff_array_reprAssertionErrorreplaceVariable)r   da_ada_br   r6   r    vavbs           r!   test_diff_array_reprz#TestFormatting.test_diff_array_repr   s   |Hiii+7;;;XsCj555Xiiiw777   77
 
 
 |HaV7+++XsCj555rxAg>>>?  D/
 
 
 =H44CC#	!, )$-%
 
4 +D$DD	CX%%%%% 	C 	C 	CX--orBBBBBBBB	C [)))7333g5O
 
 [RXyyy))).DG%T%T%TUU	/
 
 +BH==	CX%%%%%% 	C 	C 	CX--orBBBBBBBBB	Cs$   D &D76D7=G &G10G1errorc                   dt          j        ddg          i}ddi}t          d                                          }t	          j        ||d          }||k    sJ dt          j        ddg          i}t          d                                          }t	          j        ||d          }||k    sJ dt          j        g d	          i}t          d
                                          }t	          j        ||d          }||k    sJ d S )Nattrr   r   zb            Differing attributes:
            L   attr: [0 1]
            R   attr: 1
            r   r   zh            Differing attributes:
            L   attr: [0 1]
            R   attr: [-3  5]
            )r   r   r   zh            Differing attributes:
            L   attr: [0 1]
            R   attr: [0 1 2]
            )r*   r4   r   stripr   diff_attrs_repr)r   attrs_aattrs_br6   r    attrs_cs         r!   test_diff_attrs_repr_with_arrayz.TestFormatting.test_diff_attrs_repr_with_arrayE  s6   28QF++,1+
 
 %'' 	 +GWhGG6!!!!28RG,,-
 
 %'' 	 +GWhGG6!!!! 28III../
 
 %'' 	 +GWhGG6!!!!!!r#   c           	     d   t          j        dt          j        g dg dgd          fdt          j        ddgd          fd	t          j        d
dgd          t          j        g dd          dddd          }t          j        ddt          j        ddgd          fidt          j        d
dgd          ddifdt          j        ddgd          fdddi          }t          j        dk    rdnd}t          d||fz            }t          j        ||d          }||k    sJ d S )Nr   rV   r   r   r   r   r   r   )var1var2r   r   r   r   r   r   )	data_varsr   r   r   r   r   r   sourcer   r   r   r   r   r   r   a          Left and right Dataset objects are not identical
        Differing dimensions:
            (x: 2, y: 3) != (x: 2)
        Differing coordinates:
        L * x        (x) %cU1 'a' 'b'
        R * x        (x) %cU1 'a' 'c'
            source: 0
        Coordinates only on the left object:
          * y        (y) int64 1 2 3
        Coordinates only on the right object:
            label    (x) int64 1 2
        Differing data variables:
        L   var1     (x, y) int64 1 2 3 4 5 6
        R   var1     (x) int64 1 2
        Data variables only on the left object:
            var2     (x) int64 3 4
        Differing attributes:
        L   units: m
        R   units: kg
        Attributes only on the left object:
            description: descr   )	r   Datasetr*   r4   r   r   r   r   diff_dataset_repr)r   ds_ads_br   r6   r    s         r!   test_diff_dataset_reprz%TestFormatting.test_diff_dataset_reprk  s   z#RXyyy))).DG%T%T%TUbh1vW===> 
 XsCj555Xiiiw777   77

 

 

 zRXq!fG%D%D%DEF28S#Jd;;;h]KrxAg>>>?  D/
 
 
 =H44CC#	!, )$-%
 
4 -dD+FF!!!!!!r#   c                   t          j        g dg dd          }t          j        dgd          |d<   |d         }t          j        |          }t          d          }||k    sJ t          |          |k    sJ t          |          |k    sJ | }||k    sJ t          j        d	
          5  t          j        |d                   }t          d          }||k    sJ 	 d d d            d S # 1 swxY w Y   d S )NrV   )rC   bar)r   r   testr   )r   r   zk        <xarray.DataArray (1, 2) (test: 1)>
        array([0])
        Dimensions without coordinates: testFdisplay_expand_datazn            <xarray.DataArray (1, 2) (test: 1)>
            0
            Dimensions without coordinates: test)	r   r   r   r   
array_reprr   reprstrset_options)r   dsds_12r    r6   s        r!   test_array_reprzTestFormatting.test_array_repr  s   ZyyyCCDDD\1#F3336
6
 &u--0
 
 !!!! E{{h&&&&5zzX%%%% !!!!^666 		& 		&*2f:66F4 H X%%%%%		& 		& 		& 		& 		& 		& 		& 		& 		& 		& 		& 		& 		& 		& 		& 		& 		& 		&s   42C44C8;C8c                    t          j        dddg          }t          j        |           t          j        d          5  t          j        |           d d d            d S # 1 swxY w Y   d S )Nr   r   r   Fr   )r   r   r   r   r   )r   vars     r!   test_array_repr_variablez'TestFormatting.test_array_repr_variable  s    k#1v&&c"""^666 	' 	'!#&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	's   A##A'*A'c                V   t          j        dddg          }||j        d<   t          j        |           t          j        ddgdg          }||j        d<   t          j        |           ||j        d<   ||j        d<   t          j        |           t          j        |           d S )Nr   r   r   r   )r   r   r   r   r   r   )r   r   das      r!   test_array_repr_recursivez(TestFormatting.test_array_repr_recursive  s     k#1v&&	#c"""\1a&u---b!!! 	#c"""b!!!!!r#   c                    t          j        t          j        d                    }t	          |d          t          |          k    sJ t	          |d          dk    sJ t	          |d          dk    sJ dd lm} t          j        |                    d                    }t	          |d          t          |          k    sJ t          j        t                    5 }t	          |d           d d d            n# 1 swxY w Y   dt          |j                  v sJ t          j        dd	g          }t          j        t                    5 }t	          |d           d d d            n# 1 swxY w Y   d
t          |j                  v sJ d S )Nr   rc   drd   z.2fz0.00z#unsupported format string passed tog?g?z#Using format_spec is only supported)r   r   r*   r4   formatr   
dask.arrayr0   r1   	TypeErrorr   valueNotImplementedError)r   r   r   excinfos       r!   test_array_scalar_formatz'TestFormatting.test_array_scalar_format  s    l28A;;''c2$s))++++c33&&&&c5!!V++++ 	 l288A;;''c2$s))++++]9%% 	3	 	 	 	 	 	 	 	 	 	 	 	 	 	 	4GM8J8JJJJJ lC:&&].// 	73	 	 	 	 	 	 	 	 	 	 	 	 	 	 	4GM8J8JJJJJJJs$   C<<D D E++E/2E/Nr   r   )r   r   r   r"   r7   r:   r@   rN   r\   rp   rw   rz   r}   r   r   r   r   r0   markfilterwarningsr   r   r   r   r   r   r	  rg   r#   r!   r
   r
      s       * * * *>/ / / // / / /& & & && & & &*& & & &,>" >" >" >"@8 8 8 8; ; ; ;2 2 2 2
" " " "	  	  	  	 ; ; ;2MC MC MC MC^ [((#" #" #" )(#"J2" 2" 2" 2"h!& !& !& !&F' ' ' '" " " "$ K K K ]K K Kr#   r
   r   r   c                      G d d          }  | t          j        ddg          d          }t          j        d|          }d}t	          j        |d          }||                    |          k    sJ d S )	Nc                  d    e Zd Zd Zd Zd Zed
d            Zed             Zed             Z	d	S )@test_inline_variable_array_repr_custom_repr.<locals>.CustomArrayc                "    || _         || _        d S r   )r  r   )r   r  r   s      r!   r   zItest_inline_variable_array_repr_custom_repr.<locals>.CustomArray.__init__  s    DJDIIIr#   c                f    d| j          d| j         }t          |          |k    rd| j          d}|S )N(z) z) ...)r   r  r   )r   width	formatteds      r!   r   zNtest_inline_variable_array_repr_custom_repr.<locals>.CustomArray._repr_inline_  sD    5DI5555I9~~%%0	000	r#   c                    t           S r   )NotImplemented)r   argskwargss      r!   __array_function__zStest_inline_variable_array_repr_custom_repr.<locals>.CustomArray.__array_function__  s    !!r#   r   tuple[int, ...]c                    | j         j        S r   )r  r   rv   s    r!   r   zFtest_inline_variable_array_repr_custom_repr.<locals>.CustomArray.shape      :##r#   c                    | j         j        S r   )r  r   rv   s    r!   r   zFtest_inline_variable_array_repr_custom_repr.<locals>.CustomArray.dtype  r  r#   c                    | j         j        S r   )r  ndimrv   s    r!   r  zEtest_inline_variable_array_repr_custom_repr.<locals>.CustomArray.ndim  s    :?"r#   N)r   r  )
r   r   r   r   r   r  propertyr   r   r  rg   r#   r!   CustomArrayr    s        	 	 		 	 		" 	" 	" 
	$ 	$ 	$ 
	$ 
	$ 	$ 
	$ 
	# 	# 
	# 	# 	#r#   r!  r   r   r   r   r   r   )r*   r4   r   r   r   inline_variable_array_reprr   )r!  r  variabler   r    s        r!   +test_inline_variable_array_repr_custom_reprr$    s    # # # # # # # #6 K"b**C00E{3&&HI28rJJJFU((33333333r#   c                 "   t          j                    } t          j        d          5  t	          t          t          j        d                              dk     sJ 	 d d d            n# 1 swxY w Y   t          j                    | k    sJ d S )Nr   )	thresholdrR   r(   )r*   get_printoptionsr   set_numpy_optionsr   r   r+   )original_optionss    r!   test_set_numpy_optionsr*    s    *,,		%	3	3	3 / /4	#''((3...../ / / / / / / / / / / / / / /   $4444444s   5A++A/2A/c            	        t           j                            d          t           j                            dd          t           j                            ddd          t           j                            dddd          t           j                            ddd          g} | D ]4}t          j        |                              d	          dz   }|d
k     sJ 5t          j        d          }dt          j        |          vsJ t          j        d          5  dt          j        |          v sJ 	 d d d            d S # 1 swxY w Y   d S )NrR   r   r   r   r`   r   r&   r   r      r^   )display_values_threshold)	r*   randomrandnr   short_array_reprcountr+   r   r   )r   r4   	num_linesarray2s       r!   test_short_array_reprr4  !  sr   
	
	B
	2r""
	2r1%%
	Q""E   /66<<TBBQF	2~~~~~ Ys^^F
3F;;;;;;		4	4	4 < <
3F;;;;;;;< < < < < < < < < < < < < < < < < <s   E  EEc                     t          j        t          j                            ddd                    } t          |                                           }t          |          dk     sJ d S )Nr&   r   r   2   )r   r   r*   r.  r/  r   
splitlinesr   )r   r?   s     r!   test_large_array_repr_lengthr8  7  sW    	biooc1a00	1	1B"XX  ""Fv;;r#   c                (   t          j        t          j        dt          j                  d          }|                    | dz  d           t          j        | dz            5 }t          j        d	          5  t          |          }t          d
          }||k    sJ |
                                }|                                }t          d          }||k    s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 )Ni,  r   r   r   ztest.ncnetcdf4)engineFr   zy        <xarray.DataArray (test: 300)>
        [300 values with dtype=int64]
        Dimensions without coordinates: testz        <xarray.DataArray (test: 300)>
        0 1 2 3 4 5 6 7 8 9 10 11 12 ... 288 289 290 291 292 293 294 295 296 297 298 299
        Dimensions without coordinates: test)r   r   r*   r+   r   	to_netcdfopen_dataarrayr   r   r   computer   )tmp_patharr_to_storearrr    r6   
arr_loadeds         r!   test_repr_file_collapsedrC  >  s   <	#RX > > >VLLLL8i/	BBB		8i/	0	0 "C!: : : " " c0
 
 !!!![[]]
$$&&0
 
 !!!!!-" " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " "s7   &D<A&C/#D/C3	3D6C3	7DDDz display_max_rows, n_vars, n_attr))r6  r   r,  )#   r   r,  )ra   r   r,  )r   r   r,  c                   dt          j        t          j        d|                              t
                              }t          j        dt          j        d|                              t
                              }t          j        dt          j        d|                              t
                              }d |D             }d |D             }t                      }t          ||                                          D ]I\  }	}
t          j
        |	t          j        ddg          |
d         gt          |
g          	          ||	<   Jt          j        |          }||_        t          j        | 
          5  t          j        |                              d          }fd|D             }t%          |          }t'          | |          }||k    sJ t          j        |j                                      d          }fd|D             }t%          |          }||k    sJ t          j        |j                                      d          }d |D             }t%          |          }||k    sJ 	 d d d            n# 1 swxY w Y   t          j        | ddd          5  t          j        |          }t          j        |j                  }t          j        d|          }t          j        ||dz   |           }d| d| d| d| d| d}t9          |          }||k    sJ 	 d d d            d S # 1 swxY w Y   d S )N	long_namer   attr_coordc                    i | ]}|d S )r   rg   rh   ks     r!   
<dictcomp>z&test__mapping_repr.<locals>.<dictcomp>e  s    aQr#   c                <    i | ]}|t          j        d dg          S )r   r   )r*   r4   )rh   _cs     r!   rL  z&test__mapping_repr.<locals>.<dictcomp>f  s(    ///rb"(Aq6""///r#   r   r   )r   datar   r   )display_max_rowsr   c                    g | ]}|v |	S rg   rg   rh   vrF  s     r!   rj   z&test__mapping_repr.<locals>.<listcomp>u      888a1r#   c                    g | ]}|v |	S rg   rg   rR  s     r!   rj   z&test__mapping_repr.<locals>.<listcomp>|  rT  r#   c                    g | ]}d |v |	S )rH  rg   )rh   rS  s     r!   rj   z&test__mapping_repr.<locals>.<listcomp>  s    666A1r#   F)rP  display_expand_coordsdisplay_expand_data_varsdisplay_expand_attrszDimensions:r   r   max_rowsz<xarray.Dataset>
r  z)
Coordinates: (z)
Data variables: (z)
Attributes: (r   )r   addr*   r+   astyper   dictzipitemsr   r   r4   r   r   r   r   dataset_reprsplitr   mindata_vars_reprr   coords_reprr   _calculate_col_width	variablesru   dim_summary_limitedr   )rP  n_varsn_attrr   r   r   r   r   r   rS  rN  r   summarylen_summarydata_vars_print_sizer    r   
dims_startdims_valuesr6   rF  s                       @r!   test__mapping_reprrp  \  s   
 IBIa$8$8$?$?$D$DEEA")Av"6"6"="=c"B"BCCA")Av"6"6"="=c"B"BCCA1E//Q///FIQ'' 
 
2|1a&!!Q%::	
 
 
	! 
I		BBH	)9	:	:	: % %)"--33D998888g888'll"#3[AA22222+BL99??EE8888g888'llf$$$$(3399$??66g666'llf$$$$$'% % % % % % % % % % % % % % %* 
)#!&"	
 
 
 " " (,,3BLAA	,]IFF
 4)a-2B
 
 
     	 
    (##!!!!!'" " " " " " " " " " " " " " " " " "s&   C=JJJ3BMMMc                     t          j        ddg dfi          } | | j        d<   t          j        |            t          j        ddg dfi          }|| j        d<   | |j        d<   t          j        |           d S )Nr   r   rV   r   r   r   )r   r   r   r   ra  )r   ds2s     r!   test__mapping_repr_recursivers    s     
S3			*+	,	,BBHTNB *cC+,
-
-CBHTNCIdOC     r#   r&   
n_elementsintc                "   d}t          |          }d}d d t          j        |           D                                             D             }t          j        j                            |t          |          d          }||z   }||k    sJ d S )Na      Dimensions without coordinates: dim_0: 3, dim_1: 3, dim_2: 3, dim_3: 3,
                                    dim_4: 3, dim_5: 3, dim_6: 3, dim_7: 3,
                                    dim_8: 3, dim_9: 3, dim_10: 3, dim_11: 3,
                                    dim_12: 3, dim_13: 3, dim_14: 3, dim_15: 3,
                                    dim_16: 3, dim_17: 3, dim_18: 3, dim_19: 3,
                                    dim_20: 3, dim_21: 3, dim_22: 3, dim_23: 3,
                                    ...
                                    dim_76: 3, dim_77: 3, dim_78: 3, dim_79: 3,
                                    dim_80: 3, dim_81: 3, dim_82: 3, dim_83: 3,
                                    dim_84: 3, dim_85: 3, dim_86: 3, dim_87: 3,
                                    dim_88: 3, dim_89: 3, dim_90: 3, dim_91: 3,
                                    dim_92: 3, dim_93: 3, dim_94: 3, dim_95: 3,
                                    dim_96: 3, dim_97: 3, dim_98: 3, dim_99: 3z Dimensions without coordinates: c                "    g | ]\  }}| d | S )z: rg   )rh   rK  rS  s      r!   rj   z+test__element_formatter.<locals>.<listcomp>  s3       11  r#   c                    i | ]}d | d	S )dim_r   rg   rJ  s     r!   rL  z+test__element_formatter.<locals>.<dictcomp>  s      N N N1Q N N Nr#   rb   rZ  )	r   r*   r+   r`  r   corer   _element_formatterr   )rt  r6   introelementsvaluesr    s         r!   test__element_formatterr    s    RH hH.E  N N	*8M8M N N N T T V V  H W22CJJ 3  F V^Fvr#   c                     ddl m}   G d d|           } |t          j        ddg                    }t	          j        |          }|                                 |                                 d S )Nr   )LazilyIndexedArrayc                      e Zd ZddZdS )Etest_lazy_array_wont_compute.<locals>.LazilyIndexedArrayNotComputableNc                     t          d          )Nz%Computing this array is not possible.)r  )r   r   s     r!   	__array__zOtest_lazy_array_wont_compute.<locals>.LazilyIndexedArrayNotComputable.__array__  s    %&MNNNr#   r   )r   r   r   r  rg   r#   r!   LazilyIndexedArrayNotComputabler    s.        	O 	O 	O 	O 	O 	Or#   r  r   r   )xarray.core.indexingr  r*   r4   r   r   r   _repr_html_)r  r  rA  r   s       r!   test_lazy_array_wont_computer    s    777777O O O O O*< O O O *
)"(Aq6*:*:
;
;C
,s

C LLNNNOOr#   r
  )r&   )rt  ru  r   r   )
__future__r   r   textwrapr   numpyr*   pandasrE   r0   
numpy.corer   xarrayr   xarray.corer   xarray.testsr   r   r
   r$  r*  r4  r8  rC  r  parametrizerp  rs  r  r  rg   r#   r!   <module>r     s   " " " " " " 



                # # # # # #     " " " " " " 8 8 8 8 8 8 8 8aK aK aK aK aK aK aK aKH"4 "4 "4 "4J5 5 5 5< < < <,    " " " ": &;;; :" :" :"	 :"z! ! ! !    8     r#   