U
    CvfH                    @  s  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mZmZ ejejejddejejddgdd	d
 ZeddddZddddZddddZddddZddddZddddZddddZddddZddddZdddd Zddd!d"Zddd#d$Zddd%d&Zddd'd(Z ddd)d*Z!ddd+d,Z"ddd-d.Z#ddd/d0Z$ddd1d2Z%ddd3d4Z&ddd5d6Z'ddd7d8Z(ddd9d:Z)ddd;d<Z*ddd=d>Z+ddd?d@Z,dddAdBZ-dddCdDZ.dddEdFZ/dddGdHZ0dddIdJZ1dddKdLZ2dddMdNZ3dddOdPZ4dddQdRZ5dddSdTZ6dddUdVZ7dddWdXZ8dddYdZZ9ddd[d\Z:ddd]d^Z;ddd_d`Z<dddadbZ=dddcddZ>dddedfZ?ej@Adgdhgejdidj dkdkdkdkdkdldkdkdldlg
dmdejdndj dkdkdkdldldldkdldldlg
dodejdpdj dldldldkdldldldkdldlg
dqdejdrdj dldkdldldldldldldldlg
dsdejdtdj dldldldldldldldldldkg
dudejdvdj dkdldkdldkdldldldldlg
dwdejdxdj dkdldldldkdldkdldldlg
dydgdzd{dd|d}d~ZBddddZCddddZDddddZEddddZFddddZGddddZHddddZIddddZJddddZKddddZLddddZMddddZNddddZOddddZPddddZQddddZRddddZSddddZTddddZUddddZVddddZWddddZXddddZYddddZZddddZ[ddddZ\ddddZ]ddddZ^ddddZ_ej@Adgdhgejddj ddgdddgdggddddgg ddddgggddejddj ddgdddgdggddddgg ddddgggddejddj ddgddgdggddgg ddgggddejddj ddgddgdggddgg ddgggddgdzddd|ddׄZ`ej@Adgdhgejddj ddddgddddgddddggddddgddddgddddgggddejddj ddddgddddgddddggddddgddddgddddgggddejddj ddgddgddggddgddgddgggddejddj ddgddgddggddgddgddgggddgdzddd|ddބZaej@Adgdhgejddj ddgddddgdggddddgdgddddgggddejddj ddgddddgdggddddgdgddddgggddejddj ddgddgdggddgdgddgggddejddj ddgddgdggddgdgddgggddejddj ddgddddgdggddddgdgddddgggddejddj ddgddddgdggddddgdgddddgggddgdzddd|ddZbej@Adgdhgejddj ddddgddddgddddggddddgddddgddddgggddejddj ddddgddddgddddggddddgddddgddddgggddejddj ddgddgddggddgddgddgggddejddj ddgddgddggddgddgddgggddejddj ddddgddddgddddggddddgddddgddddgggddejddj ddddgddddgddddggddddgddddgddddgggddgdzddd|ddZcddddZdddddZeddddZfddddZgdddd ZhddddZiddddZjddddZkddddZlddd	d
ZmddddZnddddZoddddZpddddZqddddZrddddZsddddZtddddZuddddZvddddZwdddd Zxddd!d"ZydS (#      )annotationsN)Callable)assert_equalassert_identicalrequires_daskstr)idbytes)paramsc                 C  s   | j S N)param)request r   B/tmp/pip-unpacked-wheel-h316xyqg/xarray/tests/test_accessor_str.pydtype3   s    r   None)returnc                  C  sf   dd l m}  | jdddgdd}t|}|j  }tdddg}|j|jksXt	t
|| d S )Nr   abc)chunks   )Z
dask.arrayarrayZ
from_arrayxr	DataArrayr   lenZcomputer   AssertionErrorr   )daarrZxarrresultexpectedr   r   r   	test_dask:   s    
r"   c                 C  s   t dddg| }| d}t|}|j|}|j|}t dddg}|j|jks`t|j|jksptt	|| t	|| d S )Nfoofoofoofoooofooofommmfoof[o]+r         )
r   r   astyperecompiler   countr   r   r   r   valuespat_strpat_reZ
result_strZ	result_rer!   r   r   r   
test_countG   s    

r1   c                 C  s   t dddg| }tdddg| }tdd |D }|j|}|j|}t d	d
dg}|j|jksxt|j|jkstt	|| t	|| d S )Nr#   r$   r%   r&   omc                 S  s   g | ]}t |qS r   r*   r+   .0xr   r   r   
<listcomp>Z   s     z(test_count_broadcast.<locals>.<listcomp>r   r(      )
r   r   r)   npr   r   r,   r   r   r   r-   r   r   r   test_count_broadcastW   s    
r;   c              	   C  s  t ddddg| }|jd}|jj|dd}t ddddg}|j|jksVtt|| |jt	j
|t	jd	}|j|jkstt|| |jd
}|j|}t ddddg}|j|jkstt|| |jt	
|}|j|jkstt|| |jjdddd}t ddddg}|j|jks8tt|| |jjdddd}t ddddg}|j|jksxtt|| t	
d}tjtdd |jj|dd W 5 Q R X d S )NFooxYzfOOomMm__fOoMMM_FOO|mmmFcaseTflagszFoo|mMmr#   regexrB   ZfOz(/w+)zCMust use regular expression matching for regular expression object.matchrF   )r   r   r)   r   typer   containsr   r   r*   r+   
IGNORECASEpytestraises
ValueError)r   r.   patr    r!   r0   r   r   r   test_containsg   s>    






rQ   c                 C  s  t jddddgdd| }t jdddgd	d| }t jd
d |jD d	d}|jj|dd}t jdddgdddgdddgdddggdd	gd}|j|jkstt|| |j|}t jdddgdddgdddgdddggdd	gd}|j|jkstt|| |j|}|j|jks"tt|| |jj|ddd}t jdddgdddgdddgdddggdd	gd}|j|jkstt|| |jj|ddd}t jdddgdddgdddgdddggdd	gd}|j|jkstt|| d S )Nr<   r=   r>   r?   XZdimsr@   ZMMMYc                 S  s   g | ]}t |qS r   r4   r5   r   r   r   r8      s     z+test_contains_broadcast.<locals>.<listcomp>FrA   TrE   )	r   r   r)   datar   rK   r   r   r   )r   r.   r/   r0   r    r!   r   r   r   test_contains_broadcast   sh    	
	

	
	rV   c                 C  s   t dddddg| }|jd}t dddddg}|j|jksJtt|| |jd}t dddddg}|j|jkstt|| d S )Nomfoo_nomnombar_foor#   FT	r   r   r)   r   
startswithr   r   r   endswithr   r.   r    r!   r   r   r   test_starts_ends_with   s    
r_   c                 C  s   t jdddddgdd| }t jdd	gd
d| }|j|}t jddgddgddgddgddggdd
gd}|j|jkstt|| |j|}t jddgddgddgddgddggdd
gd}|j|jkstt|| d S )NrW   rX   rY   rZ   Zfoo_barrR   rS   r#   barrT   FTr[   r   r.   rP   r    r!   r   r   r   test_starts_ends_with_broadcast   s*      
 rb   c                  C  s0  t dgtj} t dgtj}t dgtj}t dgtj}t dgtj}t dgtj}| j }| j }| j }| j	 }	| j
 }
|j|jkst|j|jkst|j|jkst|	j|jkst|
j|jkstt|| t|| t|| t|	| t|
| d S )Nz	SOme wOrdz	Some wordz	some wordz	soME WoRDz	Some Wordz	SOME WORD)r   r   r)   r:   bytes_r   
capitalizelowerswapcasetitleupperr   r   r   )valueexp_capitalizedexp_loweredexp_swapped
exp_titledexp_upperedres_capitalizedres_loweredres_swapped
res_titledres_upperedr   r   r   test_case_bytes   s*    








rt   c                  C  sd  t dgtj} t dgtj}t dgtj}t dgtj}t dgtj}t dgtj}t dgtj}t dgtj}t dgtj}t d	gtj}	t d
gtj}
| j }| j }| j }| j	 }| j
 }| j }| jd}| jd}| jd}| jd}|j|jksZt|j|jkslt|j|jks~t|j|jkst|j|jkst|j|jkst|j|jkst|j|	jkst|j|jkst|j|
jkstt|| t|| t|| t|| t|| t|| t|| t||	 t|| t||
 d S )Nu(   SOme wOrd Ǆ ß ᾛ ΣΣ ﬃ⁵Å Ç Ⅰu(   Some word ǆ ß ᾓ σς ﬃ⁵å ç ⅰu(   some word ǆ ß ᾓ σς ﬃ⁵å ç ⅰu(   soME WoRD ǆ SS ᾛ σς FFI⁵å ç ⅰu(   Some Word ǅ Ss ᾛ Σς Ffi⁵Å Ç Ⅰu*   SOME WORD Ǆ SS ἫΙ ΣΣ FFI⁵Å Ç Ⅰu*   some word ǆ ss ἣι σσ ffi⁵å ç ⅰu%   SOme wOrd DŽ ß ᾛ ΣΣ ffi5Å Ç Iu/   SOme wOrd Ǆ ß ᾛ ΣΣ ﬃ⁵Å Ç Ⅰu-   SOme wOrd DŽ ß ᾛ ΣΣ ffi5Å Ç INFCZNFDNFKCZNFKD)r   r   r)   r:   unicode_r   rd   casefoldre   rf   rg   rh   	normalizer   r   r   )ri   rj   rk   rl   rm   rn   Zexp_casefoldedZexp_norm_nfcZexp_norm_nfkcZexp_norm_nfdZexp_norm_nfkdro   Zres_casefoldedrp   rq   rr   rs   Zres_norm_nfcZres_norm_nfdZres_norm_nfkcZres_norm_nfkdr   r   r   test_case_str  sZ    














rz   c                 C  s  t jdgdgd| }|jdd}t jdgdgd| }|j|jksNtt|| |jjdddd}t jd	gdgd| }|j|jkstt|| t jdd
gdgd| }|j|d}t jddggddgd| }|j|jkstt|| t jddgdgd| }|jj||dd}t jd	dggddgd| }|j|jksXtt|| t dddddddddg	| }t dddddddddg	| }|jdd}|j|jkstt|| |jjdddd}|j|jkstt|| |jjdddd}t dddddddddg	| }|j|jksDtt|| |jjd d!dd}t dddd"d#dd$d!d%g	| }|j|jkstt|| d S )&NfooBAD__barBADr7   rS   BAD[_]* foobarr   n	foobarBADAD[_]*yfooBbarBspamfooBspambarBADABCZAabaZBacaZCABAZdogcatZYYYZYYYabaZCYYYBYYYFrI   rA   Z
YYYYYYbYYYZBYYYcYYYZcYYYtz^.a|dogzXX-XX zXX-XX bazXX-XX cazXX-XX BAzXX-XX t)r   r   r)   r   replacer   r   r   )r   r.   r    r!   rP   replr   r   r   test_replaceQ  sj    






r   c                  C  s  t dg} dd }| jjd|dd}t dg}|j|jksBtt|| t dg} d	}d
d }| j||}t dg}|j|jkstt|| t jdgdgd} d	}t jdd dd dd gdgd}| j||}t jdddggddgd}|j|jks
tt|| d S )Nr{   c                 S  s   |  d S Nr   grouprf   r3   r   r   r   <lambda>      z'test_replace_callable.<locals>.<lambda>[a-z][A-Z]{2}r'   r   foObaD__baRbaDzFoo Bar Bazz,(?P<first>\w+) (?P<middle>\w+) (?P<last>\w+)c                 S  s   |  d S NZmiddler   r   r   r   r   r     r   ZbARr7   rS   c                 S  s   |  d S )Nfirstr   r   r   r   r   r     r   c                 S  s   |  d S r   r   r   r   r   r   r     r   c                 S  s   |  d S )Nlastr   r   r   r   r   r     r   rT   ZfOOZbAZ)r   r   r   r   r   r   r   )r.   r   r    exprP   repl2r   r   r   test_replace_callable  s4    

r   c                  C  s   t ddg} t ddg}tjdtjd}| j|d}|j|jksRt	t
|| t jddgdgd} t jddd	dggdd
gd}t jtjdtjddgd
gd}t jddgd
gd}| j||}|j|jkst	t
|| d S )Ns   abcd,àutf-8s   abcd, àz(?<=\w),(?=\w)rC   , rR   rS   s   BAcd,àrT   abZBA)r   r   decoder*   r+   UNICODEr   r   r   r   r   )r.   r!   rP   r    pat2r   r   r   r   test_replace_unicode  s&    
 r   c           
   	   C  s  t jdgdgd| }t| d}|j|d}t jdgdgd| }|j|jks\tt	|| |jj|ddd}t jd	gdgd| }|j|jkstt	|| t jt| dt| d
gdgd}|j|d}t jddggddgd| }|j|jkstt	|| t jddgdgd| }|jj||dd}t jd	dggddgd| }|j|jksvtt	|| t dg| }t| d}t
jtdd |jj|dtjd}W 5 Q R X t
jtdd |jj|ddd}W 5 Q R X t
jtdd |jj|ddd}W 5 Q R X t dg| }dd }t| d}	|jj|	|dd}t dg| }|j|jkstt	|| d S )Nr{   r7   rS   r|   r}   r~   r   r   r   r   r   r   r   r   ZfooBAD__barBAD__badz1Flags cannot be set when pat is a compiled regex.rG   rC   0Case cannot be set when pat is a compiled regex.FrA   Tc                 S  s   |  d S r   r   r   r   r   r   r     r   z-test_replace_compiled_regex.<locals>.<lambda>r   r'   r   )r   r   r)   r*   r+   r   r   r   r   r   rM   rN   rO   rL   )
r   r.   rP   r    r!   r   r   Zpat3r   Zpat4r   r   r   test_replace_compiled_regex  sb    

 

   r   c              	   C  s  t jddgdgd| }t jddgdgd| }|jdd}|j|jksRtt|| t jddgdgd| }|jjdddd	}|j|jkstt|| t jdd
gdgd| }t jddgddggddgd| }|j|d}|j|jkstt|| t jddgddggddgd| }|jj|ddd	}|j|jksPtt|| dd }t	d}d}t
jt|d |jjd|dd	 W 5 Q R X d}t
jt|d |jj|ddd	 W 5 Q R X d S )Nzf.or#   rR   rS   Zbaozf.baFrI   z.oyyZfbac                 S  s   |  d S r   r   r   r   r   r   r      r   z&test_replace_literal.<locals>.<lambda>r   z2Cannot use a callable replacement when regex=FalserG   abczCCannot use a compiled regex as replacement pattern with regex=Falser}   )r   r   r)   r   r   r   r   r   r*   r+   rM   rN   rO   )r   r.   r!   r    rP   Zcallable_replZcompiled_patmsgr   r   r   test_replace_literal  s<    




r   c              	   C  s.  | d}t |}tjdggddgd| }tjtdd |jj	|dd	 W 5 Q R X tjtdd |jj	|dd	 W 5 Q R X tjtdd |jj
|d
dd W 5 Q R X tjtdd |jj
|d
dd W 5 Q R X tjtdd |jj|d W 5 Q R X tjtdd |jj|d W 5 Q R X d S )N.*r   rR   rT   rS   z#No capture groups found in pattern.rG   ZZrP   dimXXYYrP   	group_dim	match_dimrP   r*   r+   r   r   r)   rM   rN   rO   r   extract
extractallfindallr   r/   r0   ri   r   r   r   ,test_extract_extractall_findall_empty_raises,  s    
r   c              	   C  s   d}t |}tjdggddgd| }tjtdd |jj	|d d W 5 Q R X tjtdd |jj	|d d W 5 Q R X d S )	Nz(\w+)_(\d+)a_brR   rT   rS   zDDimension must be specified if more than one capture group is given.rG   r   )
r*   r+   r   r   r)   rM   rN   rO   r   r   r   r   r   r   test_extract_multi_None_raisesE  s    
r   c              	   C  s6  d}t |}tjdggddgd| }tjtdd |jj	|dd	d
 W 5 Q R X tjtdd |jj	|dd	d
 W 5 Q R X tjtdd |jj
|dddd W 5 Q R X tjtdd |jj
|dddd W 5 Q R X tjtdd |jj|dd W 5 Q R X tjtdd |jj|dd W 5 Q R X d S )Nr   r   rR   rT   rS   r   rG   Tr   )rP   rB   r   Fr   r   )rP   rB   r   r   rP   rB   r   r   r   r   r   .test_extract_extractall_findall_case_re_raisesX  sB    
      r   c              	   C  s  d}t |}tjdggddgd| }tjtdd |jj	|dd W 5 Q R X tjtdd |jj	|dd W 5 Q R X tjtd	d |jj
|dd
d W 5 Q R X tjtd	d |jj
|ddd W 5 Q R X tjtdd |jj
|ddd W 5 Q R X tjtdd |jj
|ddd W 5 Q R X tjtdd |jj
|d
d
d W 5 Q R X tjtdd |jj
|d
d
d W 5 Q R X d S )Nz(\w+)r   rR   rT   rS   z+Dimension 'X' already present in DataArray.rG   r   z1Group dimension 'X' already present in DataArray.r   r   r   z1Match dimension 'Y' already present in DataArray.r   z9Group dimension 'ZZ' is the same as match dimension 'ZZ'.)r*   r+   r   r   r)   rM   rN   KeyErrorr   r   r   r   r   r   r   -test_extract_extractall_name_collision_raises}  sJ    
      r   c                 C  s  d}| t jkr|n
t|dd}t|}tjdddgddd	ggd
dgd| }tjdddgdddggd
dgd| }tjdgdgdggdgdgdgggd
ddgd| }|jj	|d d}|jj	|dd}|jj	|d dd}	|jj	|ddd}
|jj	|d d}|jj	|dd}|j
|j
ks$t|j
|j
ks6t|	j
|j
ksHt|
j
|j
ksZt|j
|j
kslt|j
|j
ks~tt|| t|| t|	| t|
| t|| t|| d S )N(\w+)_Xy_\d*UTF-8encodinga_Xy_0 ab_xY_10-bab_Xy_110-baab_Xy_1100abc_Xy_01-cbc_Xy_2210$abcd_Xy_-dcd_Xy_33210-dccd_Xy_332210r}   abcdef_Xy_101-fef_Xy_5543210rR   rT   rS   r   babr   abcdabcdefr   r   TrP   r   rB   r:   rw   r	   r*   r+   r   r   r)   r   r   r   r   r   )r   r/   r0   pat_compiledri   	targ_nonetarg_dimres_str_noneres_str_dimZres_str_none_caseZres_str_dim_caseres_re_none
res_re_dimr   r   r   test_extract_single_case  sZ    

  




r   c                 C  sl  d}| t jkr|n
t|dd}tj|tjd}tjdddgdd	d
ggddgd| }tjdddgdddggddgd| }tjdgdgdggdgdgdgggdddgd| }|j	j
|d dd}|j	j
|ddd}|j	j
|d d}	|j	j
|dd}
|
j|jks
t|j|jkst|	j|jks.t|
j|jks@tt|| t|| t|	| t|
| d S )Nz(\w+)?_Xy_\d*r   r   rC   r   r   r   r   Z_Xy_1r   rR   rT   rS   r   r   r   r   r}   r   r   Fr   r   r:   rw   r	   r*   r+   rL   r   r   r)   r   r   r   r   r   )r   r/   r0   r   ri   r   r   r   r   r   r   r   r   r   test_extract_single_nocase  sN    
  


r   c           	      C  s  d}| t jkr|n
t|dd}t|}tjdddgddd	ggd
dgd| }tjddgddgddggddgddgddgggd
ddgd| }|jj	|dd}|jj	|dd}|jj	|ddd}|j
|j
kst|j
|j
kst|j
|j
kstt|| t|| t|| d S )N(\w+)_Xy_(\d*)r   r   r   r   r   r   r}   r   rR   rT   rS   r   0r   110r   01r   r   101r   r   Tr   r   	r   r/   r0   r   ri   r!   res_strres_reres_str_caser   r   r   test_extract_multi_case  s@    



r   c                 C  s   d}| t jkr|n
t|dd}tj|tjd}tjdddgdd	d
ggddgd| }tjddgddgddggdd	gd	d	gddgggdddgd| }|j	j
|ddd}|j	j
|dd}|j|jkst|j|jkstt|| t|| d S )Nr   r   r   rC   r   r   r   r   r}   r   rR   rT   rS   r   r   r   10r   r   r   r   r   r   Fr   r   r   r   r/   r0   r   ri   r!   r   r   r   r   r   test_extract_multi_nocase*  s:    

r   c                 C  s   t jdddgdgd| }t jddgdgd| }|jj|d	}d
dgddggddgddggddgddggg}t j|dddgd| }|jj|dd}|jj|dd}|j|jkst|j|jkstt|| t|| d S )Nr   ab_xY_10	abc_Xy_01rR   rS   r   (\w+)_xY_(\d*)rT   r   r   r   r}   r   r   r   r   ZZzr   )	r   r   r)   r   _re_compiler   r   r   r   )r   ri   r/   r   expected_listr!   r   r   r   r   r   test_extract_broadcastO  s0    
r   c           	      C  s  d}| t jkr|n
t|dd}t|}tjdddgddd	ggd
dgd| }tjdggdggdgggdggdggdggggd
dddgd| }|jj	|ddd}|jj	|ddd}|jj	|dddd}|j
|j
kst|j
|j
kst|j
|j
kstt|| t|| t|| d S )Nr   r   r   r   r   r   abcd_Xy_r}   abcdef_Xy_101rR   rT   rS   r   r   r   r   r   r   r   TrP   r   r   rB   r:   rw   r	   r*   r+   r   r   r)   r   r   r   r   r   r   r   r   r   "test_extractall_single_single_casel  s<    
*
   

r   c                 C  s   d}| t jkr|n
t|dd}tj|tjd}tjdddgdd	d
ggddgd| }tjdggdggdgggdggd	ggdggggddddgd| }|j	j
|dddd}|j	j
|ddd}|j|jkst|j|jkstt|| t|| d S )Nr   r   r   rC   r   r   r   r   r}   r   rR   rT   rS   r   r   r   r   r   r   r   Fr   r   r:   rw   r	   r*   r+   Ir   r   r)   r   r   r   r   r   r   r   r   r   $test_extractall_single_single_nocase  s6    *
   
r   c           	      C  sT  d}| t jkr|n
t|dd}t|}tjdddgddd	ggd
dgd| }tjdgdgdggdgdgdggdgdgdgggdgdgdggdgdgdggdgdgdggggd
dddgd| }|jj	|ddd}|jj	|ddd}|jj	|dddd}|j
|j
kst|j
|j
ks t|j
|j
ks2tt|| t|| t|| d S )Nr   r   r   r   r   r   r   r}   r   rR   rT   rS   r   r   baabr   cbcr   dcddccdr   fefr   r   r   Tr   r   r   r   r   r   !test_extractall_single_multi_case  sP    

,

   

r   c                 C  s,  d}| t jkr|n
t|dd}tj|tjd}tjdddgdd	d
ggddgd| }tjdgd	gd	ggdgdgdggdgdgd	gggdgdgdggd	gd	gd	ggdgdgd	ggggddddgd| }|j	j
|dddd}|j	j
|ddd}|j|jkst|j|jkstt|| t|| d S )Nr   r   r   rC   r   r   r   r   r}   r   rR   rT   rS   r   r   r   r   r   r   r   r   r   r   r   r   r   Fr   r   r   r   r   r   r   #test_extractall_single_multi_nocase  sP    

   
r   c           	      C  s,  d}| t jkr|n
t|dd}t|}tjdddgddd	ggd
dgd| }tjddggddggddgggddggddggddggggd
dddgd| }|jj	|ddd}|jj	|ddd}|jj	|dddd}|j
|j
kst|j
|j
kst|j
|j
ks
tt|| t|| t|| d S )Nr   r   r   r   r   r   r   r}   r   rR   rT   rS   r   r   r   r   r   r   r   r   r   r   Tr   r   r   r   r   r   !test_extractall_multi_single_case  s@    

   

r   c                 C  s  d}| t jkr|n
t|dd}tj|tjd}tjdddgdd	d
ggddgd| }tjddggddggddgggdd	ggd	d	ggddggggddddgd| }|j	j
|dddd}|j	j
|ddd}|j|jkst|j|jkstt|| t|| d S )Nr   r   r   rC   r   r   r   r   r}   r   rR   rT   rS   r   r   r   r   r   r   r   r   r   r   r   Fr   r   r   r   r   r   r   #test_extractall_multi_single_nocase)  s:    
   
r   c           	      C  sx  d}| t jkr|n
t|dd}t|}tjdddgddd	ggd
dgd| }tjddgddgddggddgddgddggddgddgddgggddgddgddggddgddgddggddgddgddggggd
dd d!gd| }|jj	|d d!d"}|jj	|d d!d"}|jj	|d d!d#d$}|j
|j
ks2t|j
|j
ksDt|j
|j
ksVtt|| t|| t|| d S )%Nr   r   r   r   r   r   r   r}   r   rR   rT   rS   r   r   r   r   r   1100r   r   r   2210r   r   33210r   332210r   r   r   5543210r   r   r   Tr   r   r   r   r   r    test_extractall_multi_multi_caseI  sV    


   

r  c                 C  sP  d}| t jkr|n
t|dd}tj|tjd}tjdddgdd	d
ggddgd| }tjddgd	d	gd	d	ggddgddgddggddgddgd	d	gggdd	gddgddggd	d	gd	d	gd	d	ggdd gd!d"gd	d	ggggddd#d$gd| }|j	j
|d#d$d%d&}|j	j
|d#d$d'}|j|jks&t|j|jks8tt|| t|| d S )(Nr   r   r   rC   r   r   r   r   r}   r   rR   rT   rS   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Fr   r   r   r   r   r   r   "test_extractall_multi_multi_nocase{  sP    

   
r  c                 C  s   t jdddgdgd| }t jddgdgd| }|jj|d	}d
dggddgggddggddgggddggddgggg}t j|ddddgd| }|jj|ddd}|jj|ddd}|j|jkst|j|jkstt|| t|| d S )Nr   r   r   rR   rS   r   r   rT   r   r   r   r}   r   r   r   r   ZZXZZYr   )	r   r   r)   r   r   r   r   r   r   )r   ri   r/   r0   r   r!   r   r   r   r   r   test_extractall_broadcast  s0    
r  c                   s  d}t  |}tjdddgdddggdd	gd
 }dgg dggdgg dggg} fdd|D }tj|tjd}tj|dd	gd
}|jj	|d}|jj	|d}	|jj	|dd}
|j
|j
kst|	j
|j
kst|
j
|j
kstt|| t|	| t|
| d S )Nr   r   r   r   r   r}   r   rR   rT   rS   r   r   r   r   c                   s   g | ]} fd d|D qS )c                   s   g | ]} fd d|D qS )c                   s   g | ]} |qS r   r   r5   r   r   r   r8     s     zItest_findall_single_single_case.<locals>.<listcomp>.<listcomp>.<listcomp>r   r6   r   r  r   r   r8     s     z>test_findall_single_single_case.<locals>.<listcomp>.<listcomp>r   r6   zr  r   r   r8     s     z3test_findall_single_single_case.<locals>.<listcomp>r  r   Tr   r*   r+   r   r   r)   r:   r   object_r   r   r   r   r   r   r/   r0   ri   r   expected_dtypeexpected_npr!   r   r   r   r   r  r   test_findall_single_single_case  s*    

r  c           
        s   d}t j |t jd}tjdddgdddggd	d
gd }dgdgdggdgg dggg} fdd|D }tj|tjd}tj|d	d
gd}|j	j
|dd}|j	j
|d}	|j|jkst|	j|jkstt|| t|	| d S )Nr   rC   r   r   r   r   r}   r   rR   rT   rS   r   r   r   r   r   c                   s   g | ]} fd d|D qS )c                   s   g | ]} fd d|D qS )c                   s   g | ]} |qS r   r   r5   r  r   r   r8     s     zKtest_findall_single_single_nocase.<locals>.<listcomp>.<listcomp>.<listcomp>r   r  r  r   r   r8     s     z@test_findall_single_single_nocase.<locals>.<listcomp>.<listcomp>r   r  r  r   r   r8     s     z5test_findall_single_single_nocase.<locals>.<listcomp>r  Fr   r   r*   r+   r   r   r   r)   r:   r   r	  r   r   r   r   r   
r   r/   r0   ri   r   r  r  r!   r   r   r   r  r   !test_findall_single_single_nocase  s(    
r  c                   s  d}t  |}tjdddgdddggdd	gd
 }dgddgddggdddgg ddggg} fdd|D }tj|tjd}tj|dd	gd
}|jj	|d}|jj	|d}	|jj	|dd}
|j
|j
kst|	j
|j
kst|
j
|j
kstt|| t|	| t|
| d S )Nr   r   r   r   r   r}   r   rR   rT   rS   r   r   r   r   r   r   r   r   r   r   c                   s   g | ]} fd d|D qS )c                   s   g | ]} fd d|D qS )c                   s   g | ]} |qS r   r   r5   r  r   r   r8     s     zHtest_findall_single_multi_case.<locals>.<listcomp>.<listcomp>.<listcomp>r   r  r  r   r   r8     s     z=test_findall_single_multi_case.<locals>.<listcomp>.<listcomp>r   r  r  r   r   r8     s     z2test_findall_single_multi_case.<locals>.<listcomp>r  r   Tr   r  r
  r   r  r   test_findall_single_multi_case  s>    


r  c           
        s   d}t j |t jd}tjdddgdddggd	d
gd }dgdddgddggdddgg ddggg} fdd|D }tj|tjd}tj|d	d
gd}|j	j
|dd}|j	j
|d}	|j|jkst|	j|jkstt|| t|	| d S )Nr   rC   r   r   r   r   r}   r   rR   rT   rS   r   r   r   r   r   r   r   r   r   r   r   c                   s   g | ]} fd d|D qS )c                   s   g | ]} fd d|D qS )c                   s   g | ]} |qS r   r   r5   r  r   r   r8   B  s     zJtest_findall_single_multi_nocase.<locals>.<listcomp>.<listcomp>.<listcomp>r   r  r  r   r   r8   B  s     z?test_findall_single_multi_nocase.<locals>.<listcomp>.<listcomp>r   r  r  r   r   r8   B  s     z4test_findall_single_multi_nocase.<locals>.<listcomp>r  Fr   r   r  r  r   r  r    test_findall_single_multi_nocase&  s>    

r  c                   s  d}t  |}tjdddgdddggdd	gd
 }ddggg ddgggddggg ddgggg} fdd|D }tj|tjd}tj|dd	gd
}|jj	|d}|jj	|d}	|jj	|dd}
|j
|j
kst|	j
|j
kst|
j
|j
kstt|| t|	| t|
| d S )Nr   r   r   r   r   r}   r   rR   rT   rS   r   r   r   r   r   r   r   c                   s   g | ]} fd d|D qS )c                   s   g | ]} fd d|D qS )c                   s"   g | ]}t  fd d|D qS )c                 3  s   | ]} |V  qd S r   r   r5   r  r   r   	<genexpr>^  s     zRtest_findall_multi_single_case.<locals>.<listcomp>.<listcomp>.<listcomp>.<genexpr>tupler  r  r   r   r8   ^  s     zHtest_findall_multi_single_case.<locals>.<listcomp>.<listcomp>.<listcomp>r   r  r  r   r   r8   ^  s     z=test_findall_multi_single_case.<locals>.<listcomp>.<listcomp>r   r6   wr  r   r   r8   ]  s    z2test_findall_multi_single_case.<locals>.<listcomp>r  r   Tr   r  r
  r   r  r   test_findall_multi_single_caseP  s2    


r  c           
        s   d}t j |t jd}tjdddgdddggd	d
gd }ddggddggddgggddggg ddgggg} fdd|D }tj|tjd}tj|d	d
gd}|j	j
|dd}|j	j
|d}	|j|jkst|	j|jkstt|| t|	| d S )Nr   rC   r   r   r   r   r}   r   rR   rT   rS   r   r   r   r   r   r   r   r   r   c                   s   g | ]} fd d|D qS )c                   s   g | ]} fd d|D qS )c                   s"   g | ]}t  fd d|D qS )c                 3  s   | ]} |V  qd S r   r   r5   r  r   r   r  ~  s     zTtest_findall_multi_single_nocase.<locals>.<listcomp>.<listcomp>.<listcomp>.<genexpr>r  r  r  r   r   r8   ~  s     zJtest_findall_multi_single_nocase.<locals>.<listcomp>.<listcomp>.<listcomp>r   r  r  r   r   r8   ~  s     z?test_findall_multi_single_nocase.<locals>.<listcomp>.<listcomp>r   r  r  r   r   r8   }  s    z4test_findall_multi_single_nocase.<locals>.<listcomp>r  Fr   r   r  r  r   r  r    test_findall_multi_single_nocasep  s,    

r  c                   s@  d}t  |}tjdddgdddggdd	gd
 }ddggddgddggddgddgggddgddgddggg ddgddgggg} fdd|D }tj|tjd }tj|dd	gd
}|jj	|d!}|jj	|d!}	|jj	|d"d#}
|j
|j
kst|	j
|j
kst|
j
|j
kstt|| t|	| t|
| d S )$Nr   r   r   r   r   r}   r   rR   rT   rS   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   c                   s   g | ]} fd d|D qS )c                   s   g | ]} fd d|D qS )c                   s"   g | ]}t  fd d|D qS )c                 3  s   | ]} |V  qd S r   r   r5   r  r   r   r    s     zQtest_findall_multi_multi_case.<locals>.<listcomp>.<listcomp>.<listcomp>.<genexpr>r  r  r  r   r   r8     s     zGtest_findall_multi_multi_case.<locals>.<listcomp>.<listcomp>.<listcomp>r   r  r  r   r   r8     s     z<test_findall_multi_multi_case.<locals>.<listcomp>.<listcomp>r   r  r  r   r   r8     s    z1test_findall_multi_multi_case.<locals>.<listcomp>r  r   Tr   r  r
  r   r  r   test_findall_multi_multi_case  sH    



r  c           
        s"  d}t j |t jd}tjdddgdddggd	d
gd }ddggddgddgddggddgddgggddgddgddggg ddgdd gggg} fd!d"|D }tj|tjd#}tj|d	d
gd}|j	j
|d$d%}|j	j
|d&}	|j|jkst|	j|jks
tt|| t|	| d S )'Nr   rC   r   r   r   r   r}   r   rR   rT   rS   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   c                   s   g | ]} fd d|D qS )c                   s   g | ]} fd d|D qS )c                   s"   g | ]}t  fd d|D qS )c                 3  s   | ]} |V  qd S r   r   r5   r  r   r   r    s     zStest_findall_multi_multi_nocase.<locals>.<listcomp>.<listcomp>.<listcomp>.<genexpr>r  r  r  r   r   r8     s     zItest_findall_multi_multi_nocase.<locals>.<listcomp>.<listcomp>.<listcomp>r   r  r  r   r   r8     s     z>test_findall_multi_multi_nocase.<locals>.<listcomp>.<listcomp>r   r  r  r   r   r8     s    z3test_findall_multi_multi_nocase.<locals>.<listcomp>r  Fr   r   r  r  r   r  r   test_findall_multi_multi_nocase  sB    


r  c           
        s   t jdddgdgd }t jddgdgd }|jj|d	}d
gdggg g gdgdggg} fdd|D }tj|tjd}t j|ddgd}|jj|d	}|jj|d	}	|j	|j	kst
|	j	|j	kst
t|| t|	| d S )Nr   r   r   rR   rS   r   z\w+_Xy_(\d*)rT   r   r   r   r   r   c                   s   g | ]} fd d|D qS )c                   s   g | ]} fd d|D qS )c                   s   g | ]} |qS r   r   r5   r  r   r   r8     s     z@test_findall_broadcast.<locals>.<listcomp>.<listcomp>.<listcomp>r   r  r  r   r   r8     s     z5test_findall_broadcast.<locals>.<listcomp>.<listcomp>r   r  r  r   r   r8     s     z*test_findall_broadcast.<locals>.<listcomp>r  )r   r   r)   r   r   r:   r   r	  r   r   r   r   )
r   ri   r/   r0   r   r  r  r!   r   r   r   r  r   test_findall_broadcast  s.    
r  c                 C  s~   t ddddg| }|jd}|jd }t dddd	g| }|j|jksVt|j|jksftt|| t|| d S )
Nr   r   r   dr9   aaabbbcccdddr   r   r)   r   repeatr   r   r   )r   r.   r    
result_mulr!   r   r   r   test_repeat  s    

r%  c                 C  s   t jddddgdgd| }t jddgd	gd}|j|}|j| }t jd
dgddgddgddggdd	gd| }|j|jkst|j|jkstt|| t|| d S )Nr   r   r   r  rR   rS   r9   r(   rT   r  Zaaaar  Zbbbbr   ccccr!  Zddddr"  )r   r.   Zrepsr    r$  r!   r   r   r   test_repeat_broadcast  s    

r'  c                 C  sj  t ddg| }|jd}|j|}t ddg}|j|jksJtt|| |jt	
|}|j|jksvtt|| |jd}|j|}t ddg}|j|jkstt|| |jt	
|}|j|jkstt|| |jd}|jj|dd}t ddg}|j|jks(tt|| |jt	j
|t	jd	}|j|jks\tt|| d S )
Nr{   r#   z.*(BAD[_]+).*(BAD)TFz.*BAD[_]+.*BADz.*bAd[_]+.*badrA   rC   )r   r   r)   r   rJ   r   rH   r   r   r*   r+   rL   ra   r   r   r   
test_match%  s2    




r(  c                  C  s  t tjddd} | }t tjdtd}t tjdtd}t tjddd}|j| jdjkslt	|j| j
djkst	|j| jdjkst	|j| jdjkst	|j| j jkst	|j| j jkst	|j| j jkst	|j| j jkst	|j| j jks&t	|j| j jks>t	|j| j jksVt	|j| j jksnt	|j| j jkst	|jj| jdjjkst	|jj| jdjjkst	|jj| jdjjkst	|jj| j jjkst	|jj| jdjjkst	|jj| j jjks6t	|jj| jdjjksTt	|jj| jd	jjksrt	|jj| j jjkst	|jj| j  jjkst	|jj| j!djjkst	|jj| j"d
jjkst	|jj| j# jjkst	|jj| jj$ddjjks"t	|jj| jj$ddjjksBt	|jj| j% jjks^t	|jj| j& jjkszt	|jj| j' jjkst	|jj| j( jjkst	|jj| j)djjkst	|jj|j*djjkst	t+|| jd t+|| j
d t+|| jd t+|| jd t+|| j  t+|| j  t+|| j  t+|| j  t+|| j  t+|| j  t+|| j  t+|| j  t+|| j  t+|| jd t+|| jd t+|| jd t+|| j  t+|| jd t+|| j  t+|| jd t+|| jd	 t+|| j  t+|| j   t+|| j!d t+|| j"d
 t+|| j,dd t+|| j#  t+|| jj$dd t+|| jj$dd t+|| j%  t+|| j&  t+|| j'  t+|| j(  t+|| j)d t+||j*d t-dd}|jj| j.|jjkspt	t+|| j.| d S )N)r   U)shaper   Sr   z^aascii*   r   r9   r   )step)stopr   )/r   r   r:   emptyintboolr   r   rK   r   r]   rH   r\   isalnumisalpha	isdecimalisdigitislower	isnumericisspaceistitleisupperkindencoder,   findr   rfindrd   centergetre   lstrippadr#  rstripslicestriprf   rg   rh   wrapr   r   r   	maketrans	translate)r0  Z	empty_strZ	empty_intZ
empty_boolZempty_bytestabler   r   r   test_empty_str_methodsG  s      rK  funcr!   c                 C  s
   | j  S r   )r   r3  r7   r   r   r   r     r   r   TFr3  c                 C  s
   | j  S r   )r   r4  rM  r   r   r   r     r   r4  c                 C  s
   | j  S r   )r   r6  rM  r   r   r   r     r   r6  c                 C  s
   | j  S r   )r   r7  rM  r   r   r   r     r   r7  c                 C  s
   | j  S r   )r   r9  rM  r   r   r   r     r   r9  c                 C  s
   | j  S r   )r   r:  rM  r   r   r   r     r   r:  c                 C  s
   | j  S r   )r   r;  rM  r   r   r   r     r   r;  z&Callable[[xr.DataArray], xr.DataArray]z
list[bool])rL  r!   r   c                 C  sT   t ddddddddd	d
g
| }t |}||}|j|jksFtt|| d S )Nr   r   ZXy4Z3Ar}   ZTTZ55-z  )r   r   r)   r   r   r   )r   rL  r!   r.   expected_daactualr   r   r   test_ismethods  s    +
rR  c               	   C  s   t dddddddg} t dd	d	dd	d	dg}t dd	dddd	dg}| j }| j }|j|jkslt|j|jks|tt|| t|| d S )
Nr   3   ¼u   ★u   ፸u   ３ZfourFT)r   r   r   r8  r5  r   r   r   )r.   Zexp_numericZexp_decimalZres_numericZres_decimalr   r   r   test_isnumeric  s    


rU  c                 C  sT   ddddg}t || j }t dd |D }|j|jksFtt|| d S )Nr#   ZfoooZfoooooZfoooooooc                 S  s   g | ]}t |qS r   )r   r5   r   r   r   r8     s     ztest_len.<locals>.<listcomp>)r   r   r)   r   r   r   r   r   r^   r   r   r   test_len  s
    rV  c                   s  t dddddg}| }|jd}|jjddd}t d	d
dddg}t  fdd|jD }|j|jksxt|j|jkst|j|jkst|j|jkstt|| t|| t|| t|| |j	d}|jjddd}t d	ddd	dg}t  fdd|jD }|j|jks,t|j|jks>t|j|jksPt|j|jksbtt|| t|| t|| t|| |jdd
}|jjdd
dd}t d	d
dd	dg}t  fdd|jD }|j|jkst|j|jkst|j|jkst|j|jks tt|| t|| t|| t|| |j	dd
}|jjdd
dd}t d	ddd	dg}t  fdd|jD }|j|jkst|j|jkst|j|jkst|j|jkstt|| t|| t|| t|| |jdd
d}|jjdd
ddd}t d	d
dd	dg}t  fdd|jD }|j|jksjt|j|jks|t|j|jkst|j|jkstt|| t|| t|| t|| |j	dd
d}|jjdd
ddd}t d	d
dd	dg}t  fdd|jD }|j|jks,t|j|jks>t|j|jksPt|j|jksbtt|| t|| t|| t|| d S )NABCDEFGBCDEFEF	DEFGHIJEFEFGHEFXXXEFleftsider(   r9   r   r   r   c                   s   g | ]}|  d qS r\  r>  r6   vr  r   r   r8     s     ztest_find.<locals>.<listcomp>right      c                   s   g | ]}|  d qS r`  r?  rb  r  r   r   r8     s     c                   s   g | ]}|  d dqS r\  r9   ra  rb  r  r   r   r8     s     c                   s   g | ]}|  d dqS rh  rg  rb  r  r   r   r8     s        c                   s   g | ]}|  d ddqS r\  r9   ri  ra  rb  r  r   r   r8   )  s     c                   s   g | ]}|  d ddqS rj  rg  rb  r  r   r   r8   6  s     )
r   r   r)   r   r>  r.   r   r   r   r?  )r   r.   result_0result_1Z
expected_0Z
expected_1r   r  r   	test_find  s    























rm  c              	   C  s  t jdddddgdgd}|| }t jdd	d
gdgd| }t jddgdgd}t jddgdgd}|j|||}|jj|||dd}t jddgddgddggddgddgddggddgddgddggddgddgddggddgddgddgggdddgd}|j|jkst|j|jks(tt|| t|| |j|||}|jj|||dd}t jddgddgddggddgddgddggddgddgddggddgddgddggddgddgddgggdddgd}|j|jkst|j|jkstt|| t|| d S )NrW  rX  rY  rZ  r[  rR   rS   r\  BCr   rT   r   rf  Zri  	   r]  r^  r(   r   r   r9   rd  )	r   r   r)   r   r>  r   r   r   r?  r   r.   substartendrk  rl  r!   r   r   r   test_find_broadcastA  sL     



ru  c              	   C  s  t ddddg| }|jd}|jjddd}t dd	d
dg}|j|jksVt|j|jksftt|| t|| |jd}|jjddd}t ddddg}|j|jkst|j|jkstt|| t|| |jdd	}|jjdd	dd}t dd	ddg}|j|jks t|j|jks2tt|| t|| |jdd	}|jjdd	dd}t ddddg}|j|jkst|j|jkstt|| t|| |jddd}|jjddddd}t ddddg}|j|jkst|j|jks
tt|| t|| |jddd}|jjddddd}t dd	d
dg}|j|jksft|j|jksxtt|| t|| | t	j
krdnd}tjt| dd |jd W 5 Q R X d S )NrW  rX  rY  rZ  r\  r]  r^  r(   r9   r   r   rd  re  rf  E   Z
subsectionZ	substringz
 not foundrG   ZDE)r   r   r)   r   indexr   r   r   rindexr:   rc   rM   rN   rO   )r   srk  rl  r!   Z	matchtyper   r   r   
test_indexo  s\    











r{  c                 C  s  t jddddgdgd}|| }t jddgd	gd| }t jd
dgdgd}t jddgdgd}|j|||}|jj|||dd}t jddgddggddgd
dggddgddggd
dgddgggdd	dgd}|j|jkst|j|jkstt|| t|| |j|||}|jj|||dd}t jddgddggddgd
dggddgddggd
dgddgggdd	dgd}|j|jkst|j|jkstt|| t|| d S )NZABCDEFGEFDBCAZBCDEFEFEFDBCZDEFBCGHIEFBCZEFGHBCEFBCBCBCEFrR   rS   r\  rn  rT   r   ri  ro     r]  r^  r(   rf  r   
   r9   rw  rd  )	r   r   r)   r   rx  r   r   r   ry  rq  r   r   r   test_index_broadcast  s8    

:

:
r~  c                  C  sZ   t ddddg} tdd}| j|}t ddd	d
g}|j|jksLtt|| d S )NZabcdefgZabccZcdddfgZcdefgggr   ZcdeZcdedefgZcdeeZedddfgZedefggg)r   r   r   rH  rI  r   r   r   )r.   rJ  r    r!   r   r   r   test_translate  s    r  c                 C  sX  t ddddg| }|jd}t ddddg| }|j|jksLtt|| |jjdd	d
}|j|jksvtt|| |j	d}t ddddg| }|j|jkstt|| |jjddd
}|j|jkstt|| |j
d}t ddddg| }|j|jkstt|| |jjddd
}|j|jksJtt|| d S )Nr   r   r   Zeeeeere  z  a  z  b  z  c  bothr^  za    zb    zc    rd  z    az    bz    cr]  r   r   r)   r   r@  r   r   r   rC  ljustrjustr^   r   r   r   test_pad_center_ljust_rjust  s,    




r  c              	   C  sJ  t dddddg| }|jjddd}t d	d
dddg| }|j|jksTtt|| |jjdddd}|j|jkstt|| |jj	ddd}t dddddg| }|j|jkstt|||  |jjdddd}|j|jkstt|| |jj
ddd}t dddddg| }|j|jks<tt|||  |jjdddd}|j|jksptt|| d}tjt|jddd |jjddd W 5 Q R X tjt|jddd |jj	ddd W 5 Q R X tjt|jddd |jj
ddd W 5 Q R X tjt|jddd |jjddd W 5 Q R X d S )Nr   bbr&  dddddeeeeeere  rR   fillcharXXaXXXXbbXXccccr  r_  r  aXXXXbbXXXccccXrd  XXXXaXXXbbr]  z)fillchar must be a character, not {dtype}r   r  rG   ZXY)r   r   r)   r   r@  r   r   r   rC  r  r  rM   rN   	TypeErrorformat)r   r.   r    r!   templater   r   r   $test_pad_center_ljust_rjust_fillchar  sJ    



r  c                 C  s  t jdddddgdd| }t jdd	gd
d}t jddgd
d| }|jj||d}t jddgddgddgddgddggdd
gd| }|j|jkstt|| |jj|d|d}|j|jkstt|| |jj	||d}t jddgddgddgddgddggdd
gd| }|j|jks,tt|||  |jj|d|d}|j|jks`tt|| |jj
||d}t jddgddgddgddgddggdd
gd| }|j|jkstt|||  |jj|d|d}|j|jkstt|| d S )Nr   r  r&  r  r  rR   rS   re  r(   rT   #r  r  z#a##r  z#bb#r  r  r  r  za###r  zbb##r  rd  r  z###ar  z##bbr]  r  )r   r.   widthr  r    r!   r   r   r   %test_pad_center_ljust_rjust_broadcast"  sp    	


	

	
r  c                 C  s   t dddddg| }|jd}t ddd	d
dg| }|j|jksPtt|| |jd}t dddddg| }|j|jkstt|| d S )N122r  33345678re  Z0000100022Z00aaaZ00333r9   Z001Z022)r   r   r)   r   zfillr   r   r   r^   r   r   r   
test_zfill]  s    
r  c                 C  sr   t dddddg| }tdddd	d
g}|j|}t dddddg| }|j|jksdtt	|| d S )Nr  r  r  r  r  r(   re  r   r9   rw  Z0001r  Z00045678)
r   r   r)   r:   r   r   r  r   r   r   )r   r.   r  r    r!   r   r   r   test_zfill_broadcastk  s    r  c                   s   t dddg| }|jdd}t dddg| }|j|jksJtt|| d	D ]~\ zB|j  }t  fd
d|jD }t|||  W qX t	k
r   t
d  d d   Y qXX qXd S )Naafootwoaabartwoaabazquxr'   re  r#   r`   Zbaz))r   r9   r   )NNr   )r9   r}  r'   )r9   r   r   c                   s   g | ]}|  qS r   r   )r6   rz  rs  r.  r/  r   r   r8     s     ztest_slice.<locals>.<listcomp>z
failed on :)r   r   r)   r   rE  r   r   r   r.   
IndexErrorprint)r   r   r    r   r!   r   r  r   
test_sliceu  s    
r  c                 C  sn   t dddg| }t dddg}d}|jj||d}t d	d
dg| }|j|jks`tt|| d S )Nr  r  r  r   r'   r9   re  )rs  r/  Zafoor`   az)r   r   r)   r   rE  r   r   r   )r   r   rs  r/  r    r   r   r   r   test_slice_broadcast  s    r  c                   s   fdd}|ddddg}|ddd	dg}|j d
d}|j|jksJtt|| |ddddg}|j d
dd}|j|jkstt|| |ddddg}|j d
d
d}|j|jkstt|| |ddddg}|j d
dd}|j|jkstt|| |ddddg}|j dd d}|j|jks4tt|| |ddddg}|j d dd}|j|jksptt|| |ddddg}|j dd d}|j|jkstt|| |ddd!dg}|j d"dd}|j|jkstt|| d S )#Nc                   s   t |  S r   )r   r   r)   rM  r  r   r   r     r   z$test_slice_replace.<locals>.<lambda>shorta bit longerevenlongerthanthatr}   Zshrtza it longerZevnlongerthanthatr'   r9   Zshzrtza zit longerZevznlongerthanthatr  Zshzortza zbit longerZevzenlongerthanthatr   Zshorzza bit longezZevenlongerthanthazr   ZzrtZzerZzatZshortzza bit zngerZevenlozerthanthatri  rw  Zevenlongzerthanthati)r   slice_replacer   r   r   )r   r   r.   r!   r    r   r  r   test_slice_replace  sD    






r  c                 C  sx   t ddddg| }d}tddd dg}d	}t d
ddd	g| }|j|||}|j|jksjtt	|| d S )Nr  r  r  r}   r'   r(   re  rf  testZshtesttza test longerZevtest)
r   r   r)   r:   r   r   r  r   r   r   )r   r.   rs  r/  r   r!   r    r   r   r   test_slice_replace_broadcast  s    r  c                 C  s   t dddg| }|j }t dddg| }|j|jksFtt|| |j }t dddg| }|j|jkstt|| |j	 }t d	d
dg| }|j|jkstt|| d S )Nz  aa   z bb 
zcc  Zaar  cczaa   zbb 
z  aaz bb
r   r   r)   r   rF  r   r   r   rB  rD  r^   r   r   r   test_strip_lstrip_rstrip  s    




r  c                 C  s   t dddg| }|jd}t dddg| }|j|jksHtt|| |jd}t dddg| }|j|jkstt|| |j	d}t d	ddg| }|j|jkstt|| d S )
NxxABCxxzxx BNSDzLDFJH xxr7   ABC BNSDLDFJH ABCxxxxABCr  r^   r   r   r   test_strip_lstrip_rstrip_args  s    

r  c                 C  s   t dddg| }t dddg| }|j|}t ddd	g| }|j|jks^tt|| |j|}t d
ddg| }|j|jkstt|| |j	|}t ddd	g| }|j|jkstt|| d S )Nr  zyy BNSDzLDFJH zzr7   r   r  r  r  r  r  r  r  )r   r.   Zto_stripr    r!   r   r   r   "test_strip_lstrip_rstrip_broadcast  s    

r  c                  C  s   t ddddddddd	g	} t ddd
ddddddg	}| jjddd}|j|jksXtt|| t ddg} t ddg}| jd}|j|jkstt|| d S )Nzhello worldzhello world!zhello world!!ZabcdefabcdeZabcdefabcdefZabcdefabcdefazab ab ab ab zab ab ab ab a	zhello
world!!zabcdefabcdef
azab ab ab abzab ab ab ab
ar}   r|  T)break_long_wordsz  pre  u   ¬€耀 abadcafez  preu   ¬€耀 ab
adcaferi  r   r   r   rG  r   r   r   )r.   r!   r    r   r   r   	test_wrap		  s@    
r  c                  C  sr   t d} | jd}t d}|j|jks0tt|| | jjddd}t d}|j|jksdtt|| d S )Nz  hello world  rf  z  hello
worldF)drop_whitespacez  hello
 world
  r  )r.   r    r!   r   r   r   test_wrap_kwargs_passed8	  s    



r  c                 C  s   t dddg| }|jd }t dddg| }|j|jksFtt|| t dd	d
g| }|jd }t dddg| }|j|jkstt|| |jd }t dddg| }|j|jkstt|| d S )Na_b_cc_d_ef_g_hr'   r   r  gZ	1_2_3_4_5Z
6_7_8_9_10Z11_12re  _r}   i8)r   r   r)   r   r   r   r   r^   r   r   r   test_getH	  s    




r  c                 C  sX   t dddg| }|jdd}t dddg| }|j|jksJtt|| d S )Nr   r   r}   r'   defaultr   r   r   r)   r   rA  r   r   r   r^   r   r   r   test_get_default`	  s
    r  c                 C  s   t jdddgdgd| }t jddgdgd}|j|}t jd	d
gddgddggddgd| }|j|jksvtt|| d S )Nr  r  r  rR   rS   r   r'   rT   r   r   r   r  fr  r  )r   r.   Zindsr    r!   r   r   r   test_get_broadcastj	  s     r  c                  C  sF   t dddg} | jd}|jd}| j|jks8tt| | d S )Nr   r   u   aär   )r   r   r   r=  r   r   r   r   )rU   encodeddecodedr   r   r   test_encode_decodev	  s
    r  c               	     s  t dddg} d}tjt|d | jd W 5 Q R X dd  | jdd	}t  fd
d| j D }|j	|j	ks~t
t|| t dddg}d}tjt|d |jd W 5 Q R X dd  |jdd	}t  fdd|j D }|j	|j	kst
t|| d S )Nr   r   u   az['charmap' codec can't encode character '\\x9d' in position 1: character maps to <undefined>rG   cp1252c                 S  s   |  ddS Nr  ignore)r=  rM  r   r   r   r   	  r   z+test_encode_decode_errors.<locals>.<lambda>r  c                   s   g | ]} |qS r   r   r5   r  r   r   r8   	  s     z-test_encode_decode_errors.<locals>.<listcomp>   a   bs   azS'charmap' codec can't decode byte 0x9d in position 1: character maps to <undefined>c                 S  s   |  ddS r  )r   rM  r   r   r   r   	  r   c                   s   g | ]} |qS r   r   r5   r  r   r   r8   	  s     )r   r   rM   rN   UnicodeEncodeErrorr   r=  r.   tolistr   r   r   UnicodeDecodeErrorr   )Z
encodeBaser   r    r!   Z
decodeBaser   r  r   test_encode_decode_errors~	  s(    
r  c                 C  s"  t jdddgdddggddgd	| }d
ddgdddgdddggdddgdddgdddggg}d
ddgdddgdddggdddgdddgdddggg}t j|dddgd	| }t j|dddgd	| }|jjdd}|jjdd}|j|jkst|j|jks
tt|| t|| d S )Nabc defzspam eggs swallowred_blueztest0 test1 test2 test3r}   zabra ka da brarR   rT   rS   r    defr   eggs swallowtest0ztest1 test2 test3abraz	ka da braz	spam eggsswallowztest0 test1 test2test3z
abra ka dabrar   r   	r   r   r)   r   	partition
rpartitionr   r   r   r   r.   Zexp_part_dim_listZexp_rpart_dim_listZexp_part_dimZexp_rpart_dimZres_part_dimZres_rpart_dimr   r   r   test_partition_whitespace	  sH    

r  c                 C  s&  t jdddgdddggddgd	| }d
ddgdddgdddggdddgdddgdddggg}d
ddgdddgdddggdddgdddgdddggg}t j|dddgd	| }t j|dddgd	| }|jjddd}|jjddd}|j|jkst|j|jkstt|| t|| d S )Nzabc, defzspam, eggs, swallowr  ztest0, test1, test2, test3r}   zabra, ka, da, brarR   rT   rS   r   r   r  r   zeggs, swallowr  ztest1, test2, test3r  zka, da, braz
spam, eggsr  ztest0, test1, test2r  zabra, ka, dar  r   sepr   r  r  r   r   r   test_partition_comma	  sH    

r  c                 C  sb   t jg dgd| }t jtdddgd| }|jjddd}|j|jksTtt	|| d S NrR   rS   r   r   r   r   r  )
r   r   r)   r:   zerosr   r  r   r   r   r   r.   r!   resr   r   r   test_partition_empty
  s
    r  c                 C  s   | j jd dS Nr  r   splitrM  r   r   r   r   
  r   r   r  r   eggsr  r  r  Ztest1Ztest2r  r  kar   r  Z
split_fullc                 C  s   | j jd dS r  r   rsplitrM  r   r   r   r   
  r   Zrsplit_fullc                 C  s   | j jd ddS Nr   r   maxsplitr  rM  r   r   r   r   "
  r   zeggs	swallowztest1
test2

test3z	ka
da	braZsplit_1c                 C  s   | j jd ddS r  r  rM  r   r   r   r   *
  r   z
spam		eggsztest0
test1
test2zabra  ka
daZrsplit_1zxr.DataArrayc                   s   t jdddgdddggddgd	 } fd
d|D }tj|tjd}t j|ddgd	}||}|j|jksttt|| d S )Nr  spam		eggs	swallowr  test0
test1
test2

test3r}   abra  ka
da	brarR   rT   rS   c                   s   g | ]} fd d|D qS )c                   s   g | ]} fd d|D qS )c                   s   g | ]} |qS r   r   r5   r  r   r   r8   >
  s     zEtest_split_whitespace_nodim.<locals>.<listcomp>.<listcomp>.<listcomp>r   r  r  r   r   r8   >
  s     z:test_split_whitespace_nodim.<locals>.<listcomp>.<listcomp>r   r  r  r   r   r8   >
  s     z/test_split_whitespace_nodim.<locals>.<listcomp>r  	r   r   r)   r:   r   r	  r   r   r   r   rL  r!   r.   r  r  rP  rQ  r   r  r   test_split_whitespace_nodim
  s    (r  c                 C  s   | j jddS Nr   r  r  rM  r   r   r   r   L
  r   r}   c                 C  s   | j jddS r  r  rM  r   r   r   r   \
  r   c                 C  s   | j jdddS Nr   r   r  r  rM  r   r   r   r   l
  r   c                 C  s   | j jdddS r  r  rM  r   r   r   r   t
  r   c                   s   t jdddgdddggddgd	 } fd
d|D }tj|tjd}t j|dddgd	 }||}|j|jks|tt|| d S )Nr  r  r  r  r}   r  rR   rT   rS   c                   s   g | ]} fd d|D qS )c                   s   g | ]} fd d|D qS )c                   s   g | ]} |qS r   r   r5   r  r   r   r8   
  s     zCtest_split_whitespace_dim.<locals>.<listcomp>.<listcomp>.<listcomp>r   r  r  r   r   r8   
  s     z8test_split_whitespace_dim.<locals>.<listcomp>.<listcomp>r   r  r  r   r   r8   
  s     z-test_split_whitespace_dim.<locals>.<listcomp>r  r   r  r  r   r  r   test_split_whitespace_dimH
  s    8r	  c                 C  s   | j jdd dS N,r  r  rM  r   r   r   r   
  r   c                 C  s   | j jdd dS r
  r  rM  r   r   r   r   
  r   c                 C  s   | j jdd ddS Nr  r   r  r   r   r  rM  r   r   r   r   
  r   z,eggs,swallowztest1,test2,test3z	ka,da,brac                 C  s   | j jdd ddS r  r  rM  r   r   r   r   
  r   z
spam,,eggsztest0,test1,test2z
abra,ka,dac                 C  s   | j jdd ddS Nr  r}  r  r  rM  r   r   r   r   
  r   Zsplit_10c                 C  s   | j jdd ddS r  r  rM  r   r   r   r   
  r   Z	rsplit_10c                   s   t jdddgdddggddgd	 } fd
d|D }tj|tjd}t j|ddgd	}||}|j|jksttt|| d S )Nabc,defspam,,eggs,swallowr  test0,test1,test2,test3r}   abra,ka,da,brarR   rT   rS   c                   s   g | ]} fd d|D qS )c                   s   g | ]} fd d|D qS )c                   s   g | ]} |qS r   r   r5   r  r   r   r8   
  s     z@test_split_comma_nodim.<locals>.<listcomp>.<listcomp>.<listcomp>r   r  r  r   r   r8   
  s     z5test_split_comma_nodim.<locals>.<listcomp>.<listcomp>r   r  r  r   r   r8   
  s     z*test_split_comma_nodim.<locals>.<listcomp>r  r  r  r   r  r   test_split_comma_nodim
  s    Hr  c                 C  s   | j jdddS Nr  r   r  r  rM  r   r   r   r   
  r   c                 C  s   | j jdddS r  r  rM  r   r   r   r      r   c                 C  s   | j jddddS Nr  r   r   r  r  rM  r   r   r   r     r   c                 C  s   | j jddddS r  r  rM  r   r   r   r     r   c                 C  s   | j jddddS Nr  r   r}  r  r  rM  r   r   r   r      r   c                 C  s   | j jddddS r  r  rM  r   r   r   r   0  r   c                   s   t jdddgdddggddgd	 } fd
d|D }tj|tjd}t j|dddgd	 }||}|j|jks|tt|| d S )Nr  r  r  r  r}   r  rR   rT   rS   c                   s   g | ]} fd d|D qS )c                   s   g | ]} fd d|D qS )c                   s   g | ]} |qS r   r   r5   r  r   r   r8   L  s     z>test_split_comma_dim.<locals>.<listcomp>.<listcomp>.<listcomp>r   r  r  r   r   r8   L  s     z3test_split_comma_dim.<locals>.<listcomp>.<listcomp>r   r  r  r   r   r8   L  s     z(test_split_comma_dim.<locals>.<listcomp>r  r   r  r  r   r  r   test_split_comma_dim
  s    Xr  c                 C  s  t jdddgdgd| }t jddgdgd| }t jd	d
gddggddgddggddgddgggdddgd| }t jddgddggddgddggddgddgggdddgd| }|jjd|dd}|jjd|dd}t|| t|| t jd	dd
gdddggdddgdddggdddgdddgggdddgd| }t jd	dd
gdddggdddgdddggdddgdddgggdddgd| }|jjd|d}|jjd|d}t|| t|| d S )Nzab cd,de fgzspam, ,eggs swallowr  rR   rS   r  r  rT   r   zcd,de fgzab cdzde fgzspam,z,eggs swallowr   z ,eggs swallowr}   r   zab cd,deZfgzspam, ,eggsr  zspam, r  r   )r   r  r   r   r  )r   r   r)   r   r  r  r   r  )r   r.   r  Zexpected_leftZexpected_rightZres_leftZ	res_rightr   r   r   test_splitters_broadcastV  sp    	

	
r  c                 C  sb   t jg dgd| }t jtdddgd| }|jjddd}|j|jksTtt	|| d S r  )
r   r   r)   r:   r  r   r  r   r   r   r  r   r   r   test_split_empty  s
    r  c                 C  s  t jdddgdddggddgd	| }t jd
ddgdddggddgd	| }tdddddg| }tdddddg| }dddddgdddddgdddddggdddddgdddddgdddddggg}t|}t j|dddgd	}| }| }	||jd< ||	jd< |jjdd}
|jjddd}|jjddd}|
j	|j	ksVt
|j	|j	ksht
|j	|	j	kszt
t|
| t|| t||	 d S )Nza|ab~abc|abcr   za||abc|abcdz	abcd|ab|az
abc|ab~abcz|arR   rT   rS   za~ab|abc~~abcz
a~abc~abcdz	abcd~ab~az
abc~ab|abcz~ar   r   r   zab~abczab|abcTFr   r  |r  ~)r   r   r)   r:   r   copycoordsr   get_dummiesr   r   r   )r   Zvalues_lineZvalues_commaZ	vals_lineZ
vals_commar   r  r!   Z	targ_line
targ_commaZres_defaultZres_line	res_commar   r   r   test_get_dummies  sL    




r"  c                 C  s   t jddddgdgd| }t jddgd	gd| }d
d
dgddd
ggdd
d
gdd
d
ggdd
dgddd
ggd
d
dgdd
d
ggg}t|}t j|dd	dgd}tdddg| |jd< |jjd|d}|j|jkst	t
|| d S )Nzx~x|x~xr7   zx|x~xzx~xrR   rS   r  r  rT   FTr   zx|xr  )r   r   r)   r:   r   r  r   r  r   r   r   )r   r.   r  r   r  r!   r  r   r   r   test_get_dummies_broadcast  s.    

r#  c                 C  s`   t jg dgd| }t jtdddgd| }|jjdd}|j|jksRtt	|| d S )NrR   rS   r  r   r  )
r   r   r)   r:   r  r   r  r   r   r   r  r   r   r   test_get_dummies_empty  s
    r$  c                   s  t jdddgdddggddgd }t jdddgdddgdddggdddgdddgdddgggdddgd }dddgdddgdddggdddgdddgddddggg} fdd|D }tj|tjd}|d	 d
= t j|ddgd}t jdgdgdggdgdgdgggdddgd }t jtjg g g gg g dgggtjdddgd}|jd	 d
= |jjdd}|jj	dd}	|jjd d}
|jj	d d}|jj
dd}|jjdd}|jj
d d}|jjd d}|jjdd}|j|jkst|	j|jkst|
j|jkst|j|jks&t|j|jks8t|j|jksJt|j|jks\t|j|jksnt|j|jkstt|| t|	| t|
| t|| t|| t|| t|| t|| t|| d S )Nr}   rR   rT   rS   r   c                   s   g | ]} fd d|D qS )c                   s   g | ]} fd d|D qS )c                   s   g | ]} |qS r   r   r5   r  r   r   r8     s     zBtest_splitters_empty_str.<locals>.<listcomp>.<listcomp>.<listcomp>r   r  r  r   r   r8     s     z7test_splitters_empty_str.<locals>.<listcomp>.<listcomp>r   r  r  r   r   r8     s    z,test_splitters_empty_str.<locals>.<listcomp>r  )r   r   r   r  )r   r   r)   r:   r   r	  rU   r   r  r  r  r  r   r   r   )r   r.   Ztarg_partition_dimZtarg_partition_none_listZtarg_partition_none_npZtarg_partition_noneZtarg_split_dimZtarg_split_noneZres_partition_dimZres_rpartition_dimZres_partition_noneZres_rpartition_noneZres_split_dimZres_rsplit_dimZres_split_noneZres_rsplit_noneZres_dummiesr   r  r   test_splitters_empty_str  s    	

 







r%  c                 C  s  t jdddgdddggddgd	| }d
}t jdddgdddggddgd	| }t jdddgdddggddgd	| }t jdddgdddggddgd	| }t jdddgd d!d"ggddgd	| }|j|}|j| }|jj|d#d$}	|jj|d%d$}
|jj|d&d$}|j|jks$t|j|jks6t|	j|jksHt|
j|jksZt|j|jksltt|| t|| t|	| t|
| t|| d S )'Nr   r  r&  r  eeeefffrR   rT   rS   Z111Za111Zbb111Zcccc111Zddddd111Zeeee111Zfff111za 111zbb 111zcccc 111z	ddddd 111zeeee 111zfff 111za||111zbb||111z	cccc||111z
ddddd||111z	eeee||111zfff||111za, 111zbb, 111z	cccc, 111z
ddddd, 111z	eeee, 111zfff, 111r  r  ||r   r   r   r)   r   r   r   r   r   r   values_1values_2
targ_blank
targ_spaceZ	targ_barsr   	res_blankZres_add	res_spaceZres_barsr!  r   r   r   test_cat_str=  s\    




r2  c                 C  s  t jdddgdddggddgd	| }t jd
ddgdddggddgd	}t jdddgdddggddgd	| }t jdddgdddggddgd	| }t jdddgdd d!ggddgd	| }t jd"d#d$gd%d&d'ggddgd	| }|j|}|j| }|jj|d(d)}	|jj|d*d)}
|jj|d+d)}|j|jksBt|j|jksTt|	j|jksft|
j|jksxt|j|jkstt|| t|| t|	| t|
| t|| d S ),Nr   r  r&  r  r&  r'  rR   rT   rS   1111122233rN  555566a11111bb222cccc33Zddddd4Zeeee5555Zfff66a 11111bb 222cccc 33zddddd 4z	eeee 5555zfff 66a||11111bb||222cccc||33zddddd||4z
eeee||5555zfff||66a, 11111bb, 222cccc, 33zddddd, 4z
eeee, 5555zfff, 66r  r(  r)  r   r*  r+  r   r   r   test_cat_uniformk  sb    




rD  c                 C  s  t jdddgdddggddgd	| }t jd
ddgdgd	}t jdddgdddggddgd	| }t jdddgdddggddgd	| }t jdddgdddggddgd	| }t jdd d!gd"d#d$ggddgd	| }|j|}|j| }|jj|d%d&}	|jj|d'd&}
|jj|d(d&}|j|jks6t|j|jksHt|	j|jksZt|
j|jkslt|j|jks~tt|| t|| t|	| t|
| t|| d S ))Nr   r  r&  r  r&  r'  rR   rT   rS   r3  r4  r5  r8  r9  r:  Z
ddddd11111Zeeee222Zfff33r;  r<  r=  zddddd 11111zeeee 222zfff 33r>  r?  r@  zddddd||11111z	eeee||222zfff||33rA  rB  rC  zddddd, 11111z	eeee, 222zfff, 33r  r(  r)  r   r*  r+  r   r   r   test_cat_broadcast_right  sb    




rE  c                 C  s  t jdddgdgd| }t jdddgd	d
dggddgd}t jdddgdddggddgd| j}t jdddgdddggddgd| j}t jdddgdddggddgd| j}t jdd d!gd"d#d$ggddgd| j}|j|}|j| }|jj|d%d&}	|jj|d'd&}
|jj|d(d&}|j|jks>t|j|jksPt|	j|jksbt|
j|jkstt|j|jkstt|| t|| t|	| t|
| t|| d S ))Nr   r  r&  rT   rS   r3  r4  r5  rN  r6  r7  rR   r8  r9  r:  a4Zbb5555Zcccc66r;  r<  r=  a 4zbb 5555zcccc 66r>  r?  r@  a||4zbb||5555zcccc||66rA  rB  rC  a, 4zbb, 5555zcccc, 66r  r(  r)  r   	r   r   r)   Tr   r   r   r   r   r+  r   r   r   test_cat_broadcast_left  sj    


	




rL  c                 C  s  t jdddgdgd| }t jddgdgd}t jd	d
dgdddggddgd| j}t jdddgdddggddgd| j}t jdddgdddggddgd| j}t jdddgddd ggddgd| j}|j|}|j| }|jj|d!d"}	|jj|d#d"}
|jj|d$d"}|j|jks0t|j|jksBt|	j|jksTt|
j|jksft|j|jksxtt|| t|| t|	| t|
| t|| d S )%Nr   r  r&  rT   rS   r3  rN  rR   r8  Zbb11111Z	cccc11111rF  Zbb4Zcccc4r;  zbb 11111z
cccc 11111rG  zbb 4zcccc 4r>  z	bb||11111zcccc||11111rH  zbb||4zcccc||4rA  z	bb, 11111zcccc, 11111rI  zbb, 4zcccc, 4r  r(  r)  r   rJ  r+  r   r   r   test_cat_broadcast_both  sj    


	




rM  c                  C  s   t jddgdgd} t jdddgdgdtj}td	}d
}tjd
tjd}t jddgdgdtj}t jddgddgddggddgddgddgggdddgdtj}| jj|||||d}|j	|j	kst
t|| d S )Nr3  rN  rR   rS   r   r  r&  rT   g333333@r}   r  r  r   r   z11111 a 3.4  z11111, a, 3.4, , z11111 bb 3.4  z11111, bb, 3.4, , z11111 cccc 3.4  z11111, cccc, 3.4, , z	4 a 3.4  z4, a, 3.4, , z
4 bb 3.4  z4, bb, 3.4, , z4 cccc 3.4  z4, cccc, 3.4, , r(  )r   r   r)   r:   rc   r   rw   r   r   r   r   r   )r,  r-  Zvalues_3Zvalues_4Zvalues_5r  r!   r  r   r   r   test_cat_multiO  sH    
rN  c                 C  sp   t d| }t d| }|j }|jjdd}|j|jksHt|j|jksXtt|| t|| d S )Nr  r  r(  r   r   r)   r   joinr   r   r   )r   r.   Ztargr0  r1  r   r   r   test_join_scalar{  s    

rQ  c                 C  s   t jdddgdgd| }t d| }t d| }|j }|jjdd}|jjd	d
}|jjdd	d}|j|jkst|j|jkst|j|jkst|j|jkstt|| t|| t|| t|| d S )Nr   r  r&  rT   rS   abbcccc	a bb ccccr  r  r(  r  rO  )r   r.   r.  r/  Zres_blank_noneres_blank_yZres_space_noneres_space_yr   r   r   test_join_vector  s(    



rV  c           
   	   C  sd  t jdddgdddggddgd	| }t jd
ddgdgd	| }t jdddgdgd	| }t jddgdgd	| }t jddgdgd	| }|jjdd}|jjdd}|jjddd}|jjddd}	|j|jkst|j|jkst|j|jkst|	j|jkstt|| t|| t|| t|	| tj	t
dd |j  W 5 Q R X d S )Nr   r  r&  r  r&  r'  rR   rT   rS   ZadddddZbbeeeeZccccfffza dddddzbb eeeezcccc fffrR  ZdddddeeeefffrS  zddddd eeee fffr  r  r  z8Dimension must be specified for multidimensional arrays.rG   )r   r   r)   r   rP  r   r   r   rM   rN   rO   )
r   r.   Ztarg_blank_xZtarg_space_xZtarg_blank_yZtarg_space_yZres_blank_xrT  Zres_space_xrU  r   r   r   test_join_2d  s^    



 rW  c                 C  s|   t jdddgdgd| }t jddgdgd| }t jd	d
gdgd| }|jj|d}|j|jksntt|| d S )Nr   r  r&  rR   rS   r  r   r   rS  za, bb, ccccr(  rO  )r   r.   r  r!   r  r   r   r   test_join_broadcast  s*    rX  c            
   	   C  s   t jdddgdgdtj} d}d}d}d	}d}d }d
}t jdddgdgdtj}| jj|||||||d}	|	j|jkstt	|	| d S )N{}.{Y}.{ZZ}{},{},{X},{X}{X}-{Y}-{ZZ}rR   rS   r   333333?2.3'test'NO!1.X.None1,1.2,'test','test''test'-X-NonerR   rT   r   W
r   r   r)   r:   rw   r   r  r   r   r   
r.   pos0pos1pos2rR   rT   r   rd  r!   r  r   r   r   test_format_scalar  s,    rj  c            
   	   C  s   t jdddgdgdtj} d}d}t jdd	gd
gd}d}d}d }d}t jddgddgddggdd
gdtj}| jj|||||||d}	|	j|jkstt	|	| d S )NrY  rZ  r[  rR   rS   r   r\  r]  3.44444r   r^  r_  r`  ra  rb  rc  re  rf  r   r   r   test_format_broadcast  s8    	rl  c                  C  sv   t jdddgdgdtj} d}d}d}t jd	d
dgdgdtj}| j|||f }|j|jkshtt|| d S )N%s.%s.%s%s,%s,%s%s-%s-%srR   rS   r   r\  r]  	1.1.2.2.3	1,1.2,2.3	1-1.2-2.3	r   r   r)   r:   rw   r   r   r   r   r.   rg  rh  ri  r!   r  r   r   r   test_mod_scalar#  s$    ru  c                  C  sx   t jdddgdgdtj} d}d}d}t jd	d
dgdgdtj}| j|||d }|j|jksjtt|| d S )Nz%(a)s.%(a)s.%(b)sz%(b)s,%(c)s,%(b)sz%(c)s-%(b)s-%(a)srR   rS   r   r\  r]  z1.1.1.2z1.2,2.3,1.2z	2.3-1.2-1)r   r   r   rs  )r.   r   r   r   r!   r  r   r   r   test_mod_dict8  s$    rv  c                  C  s   t jdddgdgdtj} t jddgdgd}t jd	d
gddgddggddgdtj}| j| }|j|jksxtt|| d S )Nz%s_1z%s_2z%s_3rR   rS   r]  rk  r   z2.3_1z	3.44444_1z2.3_2z	3.44444_2z2.3_3z	3.44444_3rs  )r.   posr!   r  r   r   r   test_mod_broadcast_singleM  s&    
rx  c                  C  s   t jdddgdgdtj} d}d}t jdd	gd
gd}t jddgddgddggdd
gdtj}| j|||f }|j|jkstt|| d S )Nrm  rn  ro  rR   rS   r   r\  r]  rk  r   rp  z1.1.2.3.44444rq  z1,1.2,3.44444rr  z1-1.2-3.44444rs  rt  r   r   r   test_mod_broadcast_multic  s0    	ry  )z
__future__r   r*   typingr   Znumpyr:   rM   Zxarrayr   Zxarray.testsr   r   r   Zfixturer   Zstr_rc   r   r"   r1   r;   rQ   rV   r_   rb   rt   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  r  r  r  r%  r'  r(  rK  markZparametrizerR  rU  rV  rm  ru  r{  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r"  r#  r$  r%  r2  rD  rE  rL  rM  rN  rQ  rV  rW  rX  rj  rl  ru  rv  rx  ry  r   r   r   r   <module>'   s  
,C:6$>+%+0*(% ./# 2/)* /,"V(S.8#	3;
-/
"22
%











5







E























U@
,
K.11AA,."