U
    b                    @   s  d Z ddlZddlZddlZddlZddlmZmZ ddl	m
Z
mZmZmZ ddlmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z< G dd dZ=G d	d
 d
Z>G dd dZ?G dd dZ@G dd dZAG dd dZBG dd dZCG dd dZDG dd dZEG dd dZFG dd dZGG dd dZHG dd  d ZIG d!d" d"ZJG d#d$ d$ZKdS )%zTests suite for MaskedArray.
Adapted from the original test_ma by Pierre Gerard-Marchant

:author: Pierre Gerard-Marchant
:contact: pierregm_at_uga_dot_edu
:version: $Id: test_extras.py 3473 2007-10-29 15:18:13Z jarrod.millman $

    N)assert_warnssuppress_warnings)assert_assert_array_equalassert_equalassert_almost_equal)arrayarangemaskedMaskedArraymasked_arraygetmaskarrayshapenomaskoneszeroscount)"
atleast_1d
atleast_2d
atleast_3dmr_dotpolyfitcovcorrcoefmedianaverageuniquesetxor1d	setdiff1dunion1dintersect1din1dediff1dapply_over_axesapply_along_axiscompress_ndcompress_rowcolsmask_rowcolsclump_maskedclump_unmaskedflatnotmasked_contiguousnotmasked_contiguousnotmasked_edges
masked_allmasked_all_likeisindiagflatndenumeratestackvstackc                   @   sL   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S )TestGenericc                 C   sJ  t dtd}tddgddgtd}t|| tddgddgd}t d|d}td	d	gd
d
g|d}t|| t d|d}td	d	gd	d	ggd
d
gd
d
gg|d}t|| tddddgfg}t d|d}tddgddg|d}t|| t d|d}tddgddg|d}t|| t d
|d}tdggdgg|d}t|| d S )N   dtype   maskr9   abfnamesformatsr   r   r:   r:   r7   r7   r=   r?   bar?   Zbbr?   r:   rD   )r.   floatr   r   npr9   )selftestcontroldt rQ   >/tmp/pip-unpacked-wheel-_xqqh9v7/numpy/ma/tests/test_extras.pytest_masked_all%   s:    


 
 
zTestGeneric.test_masked_allc                 C   s   t ddtfgdffg}t jd|}tt|d t jjj tt|d d t jjj tt	|d d d t|d d j
d t|d d jj
d d S )Nr>   cr:   r:   rD   rQ   rL   r9   objectmar.   r   typecorer   lenr   Z_fill_valuerM   Zmy_dtype
masked_arrrQ   rQ   rR   "test_masked_all_with_object_nestedC   s    z.TestGeneric.test_masked_all_with_object_nestedc                 C   sr   t dtdffg}t jd|}tt|d t jjj tt	|d d t|d j
d t|d jj
d d S )Nr>   rU   r:   rD   rQ   rV   r\   rQ   rQ   rR   test_masked_all_with_objectO   s    z'TestGeneric.test_masked_all_with_objectc                 C   s   t ddgtd}t|}t ddgddgtd}t|| tddgddgd}t d	d	gd
d
g|d}t|}t ddgd
d
g|d}t|| tddddgfg}t ddgddg|d}t|}t|| d S )Nr:   r7   r8   r;   r=   r>   r?   r@   rC   rD   )
   r`   rF   rG   rI   rJ   )r   rK   r/   r   rL   r9   )rM   baserN   rO   rP   rQ   rQ   rR   test_masked_all_likeY   s     

 z TestGeneric.test_masked_all_likec           	      C   s   t ddD ]}t d| D ]}tj|td}tj||td}td| }|d| @ dk|_d}||D ]}||j|  7 }qf|t	krt
|  | q|j |_t
|  | qq
d S )Nr:      r7   r8   r   )rangerL   r	   intfullr   r<   datasumr*   r   
compressed)	rM   r?   ijkjar=   sslrQ   rQ   rR   check_clumpm   s    
zTestGeneric.check_clumpc                 C   s^   t td}t|ddddddg< t|}tddtdd	tddg}t|| | t d S 
Nr`   r   r:   r7         	      rc   )r   rL   r	   r
   r)   slicer   rp   rM   r=   rN   rO   rQ   rQ   rR   test_clump_masked}   s    
zTestGeneric.test_clump_maskedc                 C   sV   t td}t|ddddddg< t|}tddtd	dg}t|| | t d S rq   )r   rL   r	   r
   r*   rv   r   rp   rw   rQ   rQ   rR   test_clump_unmasked   s    
zTestGeneric.test_clump_unmaskedc                 C   s   t d}t|}t|td|jg tjdtd|_t|td|jg t	||dk |dkB |dkB < t|}t|tddtddg t	|d d < t|}t|g  d S )	Nr`   r   r8   ru   rs      rr   rt   )
r	   r+   r   rv   sizerL   r   boolr<   r
   )rM   r=   rN   rQ   rQ   rR   test_flatnotmasked_contiguous   s    z)TestGeneric.test_flatnotmasked_contiguousN)__name__
__module____qualname__rS   r^   r_   rb   rp   rx   ry   r}   rQ   rQ   rQ   rR   r5   #   s   

r5   c                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Ze	j
ddddgddgdddgdgdgfdddgdddggddddggddgdddggdddggfgdd Zd d! ZdS )"TestAveragec                 C   s<  t ddddgddddgd}tdt|dd	 tdt|ddddgd
 t|ddddgdd\}}td| t|dk t|d d < tt|dd	jdg t ddddgddddgd}|dd}t|d d df< tt|dd	ddg tt|dd	jd dg tddgt|dd	 t|ddd\}}t|ddg d S )N              ?       @      @TFr<   r   axisweightsr   returned      @r7   r:   r   r   )r   r   r   r   r
   r<   reshape)rM   ZottresultwtsrQ   rQ   rR   test_testAverage1   s     
zTestAverage.test_testAverage1c                 C   s  ddddddg}ddddddgddddddgg}t dtjd}tt|ddd tt|d|dd tt dtjddt d g}tt|d tjt dd	 d
  tt|ddt dd	 d  tt|ddt|ddt|ddd g tt|d |dd tt|d|ddddd	ddg tt|ddt|ddt|ddd g td}ddddddg}ddddddgddddddgg}t	d}ddddddg}	ttt
||ddd ttt
||ddd ttt
||ddjdg ttt
||	ddd tttt
||ddd t
||}
tt|
d d tt|
ddddddddg tt|
ddddg tt|
d|dddddddg d S )Nr   r:   rr   r8   r         @)r   r   r   r         (@r   g
@r   r   r   g      $@Tg     X@g      @      @)r	   rL   Zfloat_r   r   r   addreducer   r   r   r<   r   )rM   w1w2xym1m2Zm3Zm4Zm5zrQ   rQ   rR   test_testAverage2   sF     &  
zTestAverage.test_testAverage2c                 C   sf  t d}t dd }t||g||ggddd\}}tt|t| t|j|j ttddddgdd\}}tt|t| ttddd	\}}tt|t| ttdtddd
\}}tt|t| tddgddggt}t|ddgddgg}t|dd}	t|	ddg t|dd}
t|
ddg t|d d}
t|
d t|dd}
t|
ddg d S )Nrr   ru   r:   Tr   )r7   r7   ru   r   r   r   r   )r   r   r7      Fr         ?r   r   g@      ?r   )r	   r   r   r   r   r   rK   r   )rM   r=   r>   Zr1r   Zr2r   Za2dZa2dmZa2daZa2dmarQ   rQ   rR   test_testAverage3   s*    
zTestAverage.test_testAverage3c                 C   s   t dddgdd}t jj|dgdgdggd}t ddd	gdd}t||ddd
}tdgdgdggdgdgdgg}t|| d S )Nr7   ru   r   r:   FTr   rz   rr   )r   r   keepdimsr   r   r   )rL   r   r   rX   r   r   r   )rM   r   r>   wactualZdesiredrQ   rQ   rR   test_testAverage4   s    "zTestAverage.test_testAverage4c                 C   sH   t tddg}t|d t tddddgddddgd}t|d d S )	Nr:   r7   r   ru   r   FTr   )r   r   r   rM   r=   rQ   rQ   rR   test_onintegers_with_mask   s    
 z%TestAverage.test_onintegers_with_maskc                 C   s  t jdddddgdddddggtd}tdddddgdd	d
ddgg|d}t|}t | }t|j|j t|j|j t|dd}t|jddt|jddd	  }t|j|j t|j|j t|dd}t|jddt|jddd	  }t|j|j t|j|j t dddddgdddddgg}	t||	d}
t j| |	|  d}t|
j|j t|
j|j t||	dd}t|j|	ddt|j|	ddd	  }t|j|j t|j|j t||	dd}t|j|	ddt|j|	ddd	  }t|j|j t|j|j d S )Nr   r:   r8   y      ?       @y      @      @y      @      @y      @       @y              "@y              ?y       @      @y      @      @y      @      @r   r   r   r   r   r   r   r   )	rL   r   r|   r   r   ri   r   realimag)rM   r<   r=   avexpectedZav0Z	expected0Zav1Z	expected1r   ZwavZwav0Zwav1rQ   rQ   rR   test_complex  sR      zTestAverage.test_complexz<x, axis, expected_avg, weights, expected_wavg, expected_wsumr:   r7   ru   Nr   r   g      ?       @rz   rr      r   r   r   r   g      #@c           
      C   s   t jj||dd}|jt |ks&tt|| t jj|||dd}|jt |ksXtt|| t jj|||ddd\}}	|jt |kstt|| |	jt |kstt|	| d S )NT)r   r   )r   r   r   )r   r   r   r   )rL   rX   r   r   AssertionErrorr   )
rM   r   r   Zexpected_avgr   Zexpected_wavgZexpected_wsumavgZwavgZwsumrQ   rQ   rR   test_basic_keepdims0  s    

 

zTestAverage.test_basic_keepdimsc           	      C   s  t jjt ddddddgdddgdddggd}tdddgd	d}tdddgdddgd}t|d|d	d
}t dddg}t|| t|d|d	d
}t dddg}t|| t jjddddgd	d	ddgd}t|dddt jgd}t|d t jjddddgddddgddddggd	ddd	gdd	ddgdd	dd	ggd}t jj|dt jdgdd}t jjdt jt jdgd	ddd	gd}t|| t	|j
|j
 d S )Nrt   ru   r:   r   r   rz         Fr         @g     @g     @g0N@g0N@r   r   r   r   Tr   r   r         @r   g      "@r         @)rL   rX   r   r	   r   r   r   r   nanr   r<   )	rM   r=   Zweights_unmaskedZweights_maskedZavg_unmaskedZexpected_unmaskedZ
avg_maskedZexpected_maskedZavg_expectedrQ   rQ   rR   test_masked_weightsG  sF     












zTestAverage.test_masked_weights)r~   r   r   r   r   r   r   r   r   pytestmarkparametrizer   r   rQ   rQ   rQ   rR   r      s$   "	,  
 

r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestConcatenatorc                 C   s   t td tddddddg td}dddddg}t||d	}t|dd|f }tt|t t |ddddddddddddg t |jt|dd|f  d S )
N)r:   r7   ru   r   rz   rr   r:   r7   ru   r   rz   rr   r   r   )	r   r   r   r   r   r   
isinstancer   r<   )rM   r>   mdrT   rQ   rQ   rR   test_1dv  s    "zTestConcatenator.test_1dc                 C   s0  t jdd}t jdd}t t jddd}t t jddd}t||d}t||d}td||f }t|jdk t|d d d df | t|d d dd f | t|j	t j
d||f  t||f }t|jdk t|d dd d f | t|dd d d f | t|j	t j
||f  d S )Nrz   r   r   1)rz   r`   )r`   rz   )rL   randomrandZround_r   r   r   r   r   r<   Zr_)rM   Za_1Za_2Zm_1Zm_2Zb_1Zb_2r   rQ   rQ   rR   test_2d  s     zTestConcatenator.test_2dc                 C   sr   t tjjdf }t|jddg t|jd d t ddgtjjf }t|jdddg t|jd d ddg d S )Nr:   TFr7   )r   rL   rX   r
   r   r<   rg   )rM   r   rQ   rQ   rR   test_masked_constant  s    z%TestConcatenator.test_masked_constantN)r~   r   r   r   r   r   rQ   rQ   rQ   rR   r   s  s   r   c                   @   s   e Zd Zdd Zdd ZdS )TestNotMaskedc                 C   s  t tddddddddg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}t|d }t|ddg t|d}t|d ddg t|d d	dg t|d}t|d dd
g t|d ddg t|jd }t|ddg t|jd}t|d ddg t|d ddg t|jd}t|d ddg t|d ddg t|d< t|d}t|d ddg t|d ddg t|d}t|d ddg t|d ddg d S )N   rz   r   r:   r      )r   r   r:   r   r   )r   r:   r7   ru   r   )ru   ru   ru   r   r   )r   r   r7   r   ru   )r   r7   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r:   r:   r7   r   r   )r   r:   r7   r   )r   r   r7   ru   )r   r7   r   r   )r   rL   r	   r   r-   r   rg   r
   rM   rg   rN   rQ   rQ   rR   
test_edges  s>    




zTestNotMasked.test_edgesc                 C   sP  t tdddddddddddgddddddddgddddddddggd}t|d }t|tddd tdd	d td
dd g t|d}t|tddd tddd gtddd tddd gtddd tddd gtddd tddd gtddd gtddd gg tddd gg t|d}t|tddd gg tddd tddd gg d S )Nr   ru   rs   r   r:   r   r            r7   rr   rc   )r   rL   r	   r   r,   r   rv   )rM   r=   tmprQ   rQ   rR   test_contiguous  s:    





zTestNotMasked.test_contiguousN)r~   r   r   r   r   rQ   rQ   rQ   rR   r     s   "r   c                   @   s~   e Zd Zdd Zdd Zdd Zejddd	d
gejddge	j
jd	fe	j
jd
fgdd Zdd Zdd Zdd ZdS )TestCompressFunctionsc                 C   s>  t ttdddd}t dt}d|d< t||d}t|}t	|d	d
ddgddddgddddggddddgddddgddddggg t|d	}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dd-dddggg t|d}t	|d	dd
ddgdd$dddgdd%dddggd.d/d0d1d2gd3d4d5d6d7gd8d9d: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|d=}t|d>}t|d?}t	|| t	|| t	|| t|d
}t	|d	d
ddgdd!d"d#gddddgddddggd.d0d1d2gd@dAdBdCgd3d5d6d7gd8d:d;d<ggddddgd'd)d*d+gddddgddddggg t|dD}t|dE}t|dF}t	|| t	|| t	|| t|dG}t	|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|dH}t	|| t|dI}t	|d	d
ddgddddgddddggd.d0d1d2gd3d5d6d7gd8d:d;d<ggddddgddddgddddggg t|dJ}t|dK}t|dL}t	|| t	|| t	|| t|dM}t	|d	d
ddgdd!d"d#gddddgddddggddddgd'd)d*d+gddddgddddggg t|dN}t	|| d S )ON<   ru   r   rz   )ru   r   rz   Tr:   r:   r:   r   r   r7   r`                        (   *   +   ,   2   4   5   6   7   9   :   ;   r:   rr   rc   rs   rt   r   r   )   -   .   /   0   1   3   8         r   r   r      r       !   "   #   $   %   &   '   rU   r   )r   r      r      r6   r   )r   )r   r:   )r   r   r:   r7   )r   r7   )r:   r   )r   r   r   r7   )r   r   )
rL   r   listrd   r   r   astyper|   r&   r   )rM   r   r   r=   a2a3Za4rQ   rQ   rR   test_compress_nd  s    



























































	
z&TestCompressFunctions.test_compress_ndc                 C   s  t tddddddgdddgdddggd}tt|ddgdd	gg tt|ddddgd
dd	gg tt|dddgddgdd	gg t |jdddgdddgdddggd}tt|ddgd
d	gg tt|ddddgd
dd	gg tt|dddgddgd
d	gg t |jdddgdddgdddggd}tt|d	gg tt|dd
dd	gg tt|ddgdgd	gg t |jdddgdddgdddggd}tt|jd tt|djd tt|djd d S )Nrt   ru   r:   r   r   r   rz   rc   rs   rr   r7   )r   rL   r	   r   r   r'   _datar{   rM   r   rQ   rQ   rR   test_compress_rowcolsW  s$     "& "&&z+TestCompressFunctions.test_compress_rowcolsc                 C   s  t tddddddgdddgdddggd}tt|jdddgdddgdddgg tt|djdddgdddgdddgg tt|djdddgdddgdddgg t |jdddgdddgdddggd}tt|jdddgdddgdddgg tt|djdddgdddgdddgg tt|djdddgdddgdddgg t |jdddgdddgdddggd}tt|jdddgdddgdddgg tt|djdddgdddgdddgg tt|djdddgdddgdddgg t |jdddgdddgdddggd}tt|	 t
k tt|d	 t
k tt|d	 t
k tt|j	  tt|dj	  tt|dj	  d S )Nrt   ru   r:   r   r   )r   rL   r	   r   r   r(   r<   r  r   allr
   r	  rQ   rQ   rR   test_mask_rowcolsk  sN    
&
&
&z'TestCompressFunctions.test_mask_rowcolsr   Nr   r:   funcrowcols_axisc              	   C   sf   t tddddddgdddgdddggd}tt" |||d}t|t|| W 5 Q R X d S )Nrt   ru   r:   r   r   r   )r   rL   r	   r   r   DeprecationWarningr   r(   )rM   r   r  r  r   resrQ   rQ   rR   #test_mask_row_cols_axis_deprecation  s    
z9TestCompressFunctions.test_mask_row_cols_axis_deprecationc                 C   s   t dd}ddddddg}t||ddd}t||ddd}t||dd}t|jddgddgg t||dd}t|jdddgdddgdddgg t||d	d}t|t |d|d t||d	d}t|t |d|d ddddddg}t||ddd}t||ddd}t||dd}t|jddgddgg t||dd}t|jdddgdddgdddgg t||d	d}t|t |d|d t|t|| t||d	d}t|t |d|d ddddddg}t||ddd}t||ddd}t||}t|jt t||}t|jt t|ddddddgddd}t|ddddddgddd}t||dd}t|jddgddgg t||d	d}t|t |d|d t||dd}t|jdddgdddgdddgg t||d	d}t|t |d|d t|ddddddgddd}t|ddddddgddd}t||dd}t|jddgddgg t||}t|t |d|d t||dd}t|jdddgdddgdddgg t||d	d}t|t |d|d t|ddddddgddd}t|ddddddgddd}t||dd}t|jddgddgg t||d	d}t|t |d|d t||dd}t|jdddgdddgdddgg t||d	d}t|t |d|d d S )
Nr:   rc   r   r   r7   ru   T)strictF)	rL   r	   r   r   r   r   r<   filledr   )rM   nr   r=   r>   rT   rQ   rQ   rR   test_dot  sz    $$

  $  
$  $zTestCompressFunctions.test_dotc                 C   sn   t d}t|}ttt||tk ttt||tk ttt||tk ttt||tk d S )Nru   )rL   eyer   r   rY   r   r   rM   r=   r>   rQ   rQ   rR   test_dot_returns_maskedarray  s    
z2TestCompressFunctions.test_dot_returns_maskedarrayc                 C   sD   t td}t td}t|||d}t||k t|| d S )Nru   )ru   ru   out)r   rL   r  r   r   r   r   )rM   r=   r  r  rQ   rQ   rR   test_dot_out  s
    z"TestCompressFunctions.test_dot_out)r~   r   r   r  r
  r  r   r   r   rL   rX   Z	mask_rowsZ	mask_colsr  r  r  r  rQ   rQ   rQ   rR   r     s   p 	F	r   c                   @   s   e Zd Zdd Zdd ZdS )TestApplyAlongAxisc                 C   s@   t dddd}dd }t|d|}t|ddgdd	gg d S )
Nr   r7   ru   c                 S   s   | d S Nr:   rQ   )r>   rQ   rQ   rR   myfunc  s    z*TestApplyAlongAxis.test_3d.<locals>.myfuncr:   r   rc   r`   r	   r   r%   r   rM   r=   r  ZxarQ   rQ   rR   test_3d  s    zTestApplyAlongAxis.test_3dc                 C   sF   t dddd}ddd}t|d|dd}t|dd	gd
dgg d S )Nr   r7   ru   r   c                 S   s   | d|  S r  rQ   )r>   offsetrQ   rQ   rR   r    s    z1TestApplyAlongAxis.test_3d_kwargs.<locals>.myfuncr:   )r"  rz   rs   r   )r   r  r   rQ   rQ   rR   test_3d_kwargs  s    
z!TestApplyAlongAxis.test_3d_kwargsN)r~   r   r   r!  r#  rQ   rQ   rQ   rR   r    s   
r  c                   @   s   e Zd Zdd ZdS )TestApplyOverAxesc                 C   s   t dddd}ttj|ddg}tdgdgdggg}t|| t||d t	< ttj|ddg}td	gd
gdggg}t|| d S )Nr   r7   ru   r   r   r   \   |   r   r   )
r	   r   r$   rL   rh   r   r   r
   r  r|   )rM   r=   rN   ZctrlrQ   rQ   rR   
test_basic  s    
zTestApplyOverAxes.test_basicN)r~   r   r   r'  rQ   rQ   rQ   rR   r$    s   r$  c                   @   s   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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-S ).
TestMedianc                 C   s4   t jjt jt jgt jt jggdd}t|t j d S )Nr   r   )rL   rX   r   infr   rM   rrQ   rQ   rR   test_pytype  s    $zTestMedian.test_pytypec                 C   s   t jjt jt jt jgt jt jggdd}t|t j t jjt jt jt jgt jt jggd d}t|t j t jjt jjt jt jgt jt jggdddd}t|jd t jjt jjt jt jgt jt jggddd d}t|jd d S )Nr   r   Tr   )rL   rX   r   r   r)  r   r<   r*  rQ   rQ   rR   test_inf  s8    



zTestMedian.test_infc                 C   sl  t d}tt j|d ttt j|tk	 td}tt j|d ttt j|tk	 d}tt j|d ttt j|tk	 t d	dd}tt jj|dd	t j|dd	 tt jj|d
d	t j|d
d	 tt jj|d
d	tk	 t d	dd}tt jj|dd	t j|dd	 tt jj|d
d	t j|d
d	 tt jj|d
d	tk	 d S )Nrt   r   rs   r   rz   r   H   r   r   r:   g      R@)
rL   r	   r   rX   r   r   rY   r   rd   r   r	  rQ   rQ   rR   test_non_masked(  s"    
    zTestMedian.test_non_maskedc                 C   s  t tddgd dgd  d}ttj|d ttj|jdd tttj|t	k	 t td	
d
ddgd dgd  d}ttj|d ttj|jdd tttj|t	k	 tjj|ddd}t|ddg t|jdd tt|t	k dS )z5test the examples given in the docstring of ma.medianrs   r   r   r:   r   r   rQ   shape mismatchr`   r7   rz   rr   r   r   Tr   Zoverwrite_inputr   r   r6   N)r   rL   r	   r   rX   r   r   r   rY   r   r   )rM   r   Zma_xrQ   rQ   rR   test_docstring_examples=  s    "*z"TestMedian.test_docstring_examplesc                 C   s   d}t dD ]}dD ]}td||d}tt | |ddg}|D ]H\}}ztjj|||d W qB tk
r   t|||||f Y qBX qBt|d  |gddg}|D ]J\}}ztjj|||d W n tj	k
r   Y qX t|||||f qqqd S )	Nz5mask = %s, ndim = %s, axis = %s, overwrite_input = %srz   )FTr:   )ndminr<   FTr1  )
rd   r   	itertoolsproductrL   rX   r   	Exceptionr   Z	AxisError)rM   msgr3  r<   r   argsr   ZoverrQ   rQ   rR   test_axis_argument_errorsL  s"    z$TestMedian.test_axis_argument_errorsc                 C   sD   t ddd}ttj|d t ddd}ttj|tjj d S )Nr:   Fr   T)r   r   rL   rX   r   r
   r	  rQ   rQ   rR   test_masked_0dd  s    zTestMedian.test_masked_0dc                 C   s  t tddd}ttj|tjj ttj|jdd tt	tj|tjj
jk t tddd}ttj|d ttj|jdd tt	tj|tk	 t tddd	dddgd}ttj|d
 ttj|jdd tt	tj|tk	 t tddd	d	d	d	gd}ttj|d ttj|jdd tt	tj|tk	 t tddd	d	ddgd}ttj|d ttj|jdd tt	tj|tk	 t tddd	d	ddgd}ttj|d ttj|jdd tt	tj|tk	 t tddd	d	d	d	dgd}ttj|d
 ttj|jdd tt	tj|tk	 t tddd	d	d	d	dgd}ttj|d
 ttj|jdd tt	tj|tk	 d S )Nrz   Tr   rQ   r0  Fr   r   r:   r   r   r   r   rr   r   )r   rL   r	   r   rX   r   r
   r   r   rY   rZ   ZMaskedConstantr   r	  rQ   rQ   rR   test_masked_1dk  s@    zTestMedian.test_masked_1dc              	   C   sJ   t tjtdddgdddgdjtjtdddgdddgdj d S )Nr:   r7   ru   r   r   )r   rL   rX   r   r   r   rM   rQ   rQ   rR   test_1d_shape_consistency  s    " z$TestMedian.test_1d_shape_consistencyc                 C   s   d\}}t tdd|}t |d d< |dd < t tj||ftd}|d d  |d d df< tt|}td|D ]$}tj	
| || |d d |f< qxtt|d d df d tt|d tt|dd	t| tt|jdd	t| d S )
N)e   r         r   r`   r8   r   r:   r   )r   rL   Zlinspacer
   emptyrK   r	   r[   rd   r   shuffler   r   r   T)rM   r  pr   r   idxrj   rQ   rQ   rR   r     s    zTestMedian.test_2dc                 C   s   t tddd}t |d d< |dd < tt|d tttj	|t
k	 tt|ddddd	g tttj	j|ddt
k tt|d
dddddddddddg
 tttj	j|d
dt
k tt|d
djd
d
d
ddddd
d
d
g
 d S )Nr   r`   ru         -@r   r         +@g      /@r:   r   r   r   )r   rL   r	   r   r
   r   r   r   rY   rX   r   r<   r	  rQ   rQ   rR   test_2d_waxis  s    &zTestMedian.test_2d_waxisc                 C   s   t jdddd}t||d dk< tt|dddgdd	gddgd
d	gg d|_tt|dddgddgddgg t jdddd}t||d dk< tt|dddgddgddgg d S )Nr   ru   r   r7   r   r   rt   rr   r   r   )r   ru   r7   c   r`   r   r   r   rz   rs   r   r   )rL   rX   r	   r   r
   r   r   r   r	  rQ   rQ   rR   r!    s    ("zTestMedian.test_3dc                 C   sL   t tddd}t |d d< |dd < tt|ddt|dd d S )Nr   r`   ru   rF  r   r   r:   )r   rL   r	   r   r
   r   r   r	  rQ   rQ   rR   test_neg_axis  s    zTestMedian.test_neg_axisc                 C   s   dD ]~}t t|}t |d d< |dd < t td}t||d}|dkr\t|d n
t|d t||k tt|t	k qd S )	N)r         >@r   g      ?@ru   rF  rQ   r  r   rG  g      .@)
r   rL   r	   r
   r   r   r   r   rY   r   )rM   vr   r  r+  rQ   rQ   rR   test_out_1d  s    
zTestMedian.test_out_1dc                 C   s  dD ]}t t|dd}t |d d< |dd < t td}t|d|d}|dkrt d	gd dd
ddg d	gd  dgd dgd  dgd  d}nBt d	gd ddddg d	gd  dgd dgd  dgd  d}t|| t||k tt	|t
k qd S )N)r   g      D@r   rL  r`   r   ru   rF  r:   )r   r  r   r   r   r   r   TFr   r   rH  g     1@g     5@g     9@)r   rL   r	   r   r
   r   r   r   r   rY   r   )rM   rM  r   r  r+  erQ   rQ   rR   test_out  s    
  
zTestMedian.test_outc                 C   sF   ddgddgddgg}t j|d}ddg}tt jj|dd| d S )Nr   r   r   r   r   )rL   rX   Zmasked_equalr   r   )rM   rg   r]   r   rQ   rQ   rR   $test_single_non_masked_value_on_axis  s    z/TestMedian.test_single_non_masked_value_on_axisc                 C   s  dt jdtdfD ]}t jdt jdgdddgg}||_t jj|d d}tt 	| t
|t j t jj| dd}tt 	| t
|t j t jj|dd}tt|t t
|dt jdg t jj|dd}tt|t t
|t jdg t jj|d	d}tt|t t
|t jdg qt jdt jdgdddgg}t jj|d d df< t
t jj|d dt j t
t jj|dddt jdg t
t jj|ddt jd
g d S )NFrr   r8   r:   ru   r7   r   r   r   r   )rL   r   r|   rX   r   r   r<   r   r   isscalarr   Zravelr   rY   r   r
   )rM   r<   dmr+  rQ   rQ   rR   test_nan  s.    zTestMedian.test_nanc                 C   s   t jt d}t jt d}t j|d< t jj|d< tt jj|d|d| t jt d}tt jj|d|d| t jt d	}tt jj||d| d S )
N)r   ru   r   r7   r:   rE   r   r  ru   r:   rQ   )	rL   rX   r   r   r   r   r
   r   r   )rM   or   rQ   rQ   rR   test_out_nan  s    
zTestMedian.test_out_nanc                 C   s  t jt jdtd}t jj|d d d< t j|d< tt j|t j tt jj|ddt j t jt jdtd	ddd}t |j
d dk|_| }t j|d	< t j|d
< tt j|t j tt t j| t jj|dd}t j|d< t j|d< tt j|d| t jj|dd}t j|d< t j|d< tt j|d| t jj|dd}t j|d< t j|d< tt j|d| d S )Nr   r8   ru   r7   r   r   r   r:   )r:   r7   ru   )r:   r:   r7   r7   ru   r  r:   ru   r  )rL   rX   r   r	   rK   r
   r   r   r   r   r{   r<   copyr   rR  r   )rM   r=   Zaorigr>   rQ   rQ   rR   test_nan_behavior  s0    
 







zTestMedian.test_nan_behaviorc                 C   s   t jdddgdddggt jd}t jj||dkd}tt jj|ddd tt jj|ddjd tt jj|dd|d  tt j|d d S )	Nru      r8   r   r:   r   Fr   )rL   r   Zuint8rX   r   r   r   r<   r   rQ   rQ   rR   test_ambigous_fill4  s     zTestMedian.test_ambigous_fillc                 C   s  t jt j fD ]}t |t jgt jt jgg}t jj|t |d}tt jj|dd|t jg tt jj|dd|t jg tt j|| t t jt j|gt jt j|gg}t jj|t |d}t	t jj|dd| t	t jj|ddj
d t	t jj|dd|d  t	t j|| t ||g||gg}tt j|| tt jj|dd| tt jj|dd| t j|d| dgdt jt jd	gd
t jt j|ggt jd}t jj|t |d}|dkrtt jj|dddd| dg tt j|d n2tt jj|dddd| dg tt j|d tt jj|dddd|g tddD ]}tddD ]}t t jg| |g|  gd }t jj|t |d}tt j|| tt jj|dd| tt jj|ddt jg| |g|   qhqZqd S )Nr   r   r   r:   Frc   ir@  rz   r   r8   r   r   r   g      @g      $g      "g      r?  r`   r7   )rL   r)  r   r   rX   r   isnanr   r   r   r<   Zfloat32rd   )rM   r)  r=   rj   rk   rQ   rQ   rR   test_special=  sL    "
  "zTestMedian.test_specialc              	   C   st  t jt jg td}t 8}|t tt j	|t j
 t|jd jtk W 5 Q R X t jt jg tdd}t F}|t tddt tt j	|t j
 t|jd jtk W 5 Q R X t jt jg tdd}tt jj	|dd| tt jj	|d	d| t jt jt j
tdd}tjd
d<}tddt tt jj	|dd| t|d jtk W 5 Q R X d S )Nr8   r   ru   )r9   r3  always r7   r   r:   T)record)rL   rX   r   r   rK   r   rd  RuntimeWarningr   r   r   r   logcategorywarningsfilterwarningsr   catch_warnings)rM   r=   r   r>   rQ   rQ   rR   
test_emptyh  s&    

zTestMedian.test_emptyc                 C   sX   t jt d}ttt j|tt	 t j
|d< ttt j|tt	 d S )Nr   r7   )rL   rX   r   r	   r   rY   r   r  rW   rK   r   )rM   rX  rQ   rQ   rR   test_object  s    
zTestMedian.test_objectN)r~   r   r   r,  r-  r/  r2  r9  r:  r;  r=  r   rI  r!  rK  rN  rP  rQ  rT  rY  r]  r_  ra  rk  rl  rQ   rQ   rQ   rR   r(    s,   &	#	+r(  c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )TestCovc                 C   s   t tjd| _d S Nr   )r   rL   r   r   rg   r<  rQ   rQ   rR   setup  s    zTestCov.setupc                 C   sZ   | j }tt|t| ttj|ddt|dd ttj|dddt|ddd d S )NFrowvarTrq  bias)rg   r   rL   r   r	  rQ   rQ   rR   test_1d_without_missing  s    zTestCov.test_1d_without_missingc                 C   sb   | j dd}tt|t| ttj|ddt|dd ttj|dddt|ddd d S )Nru   r   Frp  Trr  )rg   r   r   rL   r   r	  rQ   rQ   rR   test_2d_without_missing  s    zTestCov.test_2d_without_missingc                 C   s@  | j }t|d< || 8 }| }tt|t| ttj|ddt|dd ttj|dddt|ddd zt|dd W n tk
r   Y nX |dd }tt||d d d t||d d d  ttj||d d d ddt||d d d dd ttj||d d d dddt||d d d ddd d S )Nr   Frp  Trr  Zallow_maskedr:   )rg   r
   meanri   r   rL   r   
ValueError)rM   r   nxrQ   rQ   rR   test_1d_with_missing  s*    ,zTestCov.test_1d_with_missingc                 C   s6  | j }t|d< |dd}tt|t}t||j	}||
dd d d f  d}tt|t||jd d  |d   tt|ddtj|dd|jd  |  t|j	|}||
d d}tt|d	d
tj|d	d
|jd d  |d   tt|d	ddtj|d	dd|jd  |  d S )Nr   ru   r   r:   r   r   Trs  Frp  rr  )rg   r
   r   rL   Zlogical_notr   r  re   r   rC  rw  r  r   r   r   )rM   r   validfracZxfrQ   rQ   rR   test_2d_with_missing  s8     zTestCov.test_2d_with_missingN)r~   r   r   ro  rt  ru  rz  r~  rQ   rQ   rQ   rR   rm    s
   rm  c                   @   sD   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S )TestCorrcoefc                 C   s(   t tjd| _t tjd| _d S rn  )r   rL   r   r   rg   data2r<  rQ   rQ   rR   ro    s    zTestCorrcoef.setupc              	   C   s   | j | j }}t|}t||}t }td ttt|dd |	td t
tj|ddt|dd t
t|dd| t
t||dd| t
t|dd| t
t||dd| W 5 Q R X d S )Nrb  r   Zddofbias and ddof have no effectr   ru   rg   r  rL   r   r   rh  simplefilterr   r  filterr   )rM   r   r   r   Z	expected2suprQ   rQ   rR   	test_ddof  s    

zTestCorrcoef.test_ddofc              	   C   s   | j | j }}t|}t b}td ttt||dd ttt||dd ttt|dd |	td t
t|dd| W 5 Q R X d S )Nrb  TFr{  r  r:   r  )rM   r   r   r   r  rQ   rQ   rR   	test_bias  s    

zTestCorrcoef.test_biasc              	   C   sx   | j }tt|t| ttj|ddt|dd t 2}|td ttj|dddt|ddd W 5 Q R X d S )NFrp  r  Trr  )rg   r   rL   r   r   r  r  rM   r   r  rQ   rQ   rR   rt    s    
z$TestCorrcoef.test_1d_without_missingc              	   C   s   | j dd}tt|t| ttj|ddt|dd t 2}|td ttj|dddt|ddd W 5 Q R X d S )Nru   r   Frp  r  Trr  )rg   r   r   rL   r   r   r  r  r  rQ   rQ   rR   ru    s    
z$TestCorrcoef.test_2d_without_missingc              	   C   s  | j }t|d< || 8 }| }tt|t| ttj|ddt|dd t 2}|t	d ttj|dddt|ddd W 5 Q R X zt|dd W n t
k
r   Y nX |dd }tt||d d d t||d d d  ttj||d d d ddt||d d d dd t r}|t	d tt||d d d t||d d d dd	 tt||d d d t||d d d d
d W 5 Q R X d S )Nr   Frp  r  Trr  rv  r:   r{  r7   r  )rg   r
   rw  ri   r   rL   r   r   r  r  rx  )rM   r   ry  r  rQ   rQ   rR   rz    s<    
,z!TestCorrcoef.test_1d_with_missingc              	   C   s  | j }t|d< |dd}t|}t|}t|d dd df |d dd df  t }|td tt|ddd dd df |d dd df  tt|ddd dd df |d dd df  tt|ddd dd df |d dd df  W 5 Q R X d S )	Nr   ru   r   r  r   r  r:   r{  )	rg   r
   r   r   rL   r   r   r  r  )rM   r   rN   rO   r  rQ   rQ   rR   r~  &  s"    
*z!TestCorrcoef.test_2d_with_missingN)
r~   r   r   ro  r  r  rt  ru  rz  r~  rQ   rQ   rQ   rR   r    s   r  c                   @   s   e Zd Zdd Zdd ZdS )TestPolynomialc                 C   s  t jd}t jddd}tt||dt ||d |t}t|d< |t}t |d< |d< t||d d df dd	d
\}}}}}t j|dd  |dd df 	 dd	d
\}}	}
}}t
|||||f||	|
||fD ]\}}t|| qt||d d df dd	d
\}}}}}t j|dd |dddf dd	d
\}}	}
}}t
|||||f||	|
||fD ]\}}t|| qht||dd	d
\}}}}}t j|dd |ddd d f dd	d
\}}	}
}}t
|||||f||	|
||fD ]\}}t|| qt jdd }| }|dd }|dd }|dd }t||dd	|d\}}}}}t j||dd	|d\}}	}
}}t|| t
|||||f||	|
||fD ]\}}t|| qd S )Nr`   r   r   r7   ru   r   rC   r   r   Trf   r:   )rf   r   )rL   r   r   r   r   r   viewr   r
   ri   zipr\  r   )rM   r   r   CRKSDrT   r+  rl   rn   r   r=   a_r   ZwoxsZyswsrQ   rQ   rR   test_polyfit<  s>    

&"&&0&4&
&zTestPolynomial.test_polyfitc                 C   s   t jd}t jddd}t j|d< t j|d< |t}|t}t|d< t|d< t||ddd	\}}}}}t j|d
d |d
dd d f ddd	\}}	}
}}t	|||||f||	|
||fD ]\}}t
|| qd S )Nr`   r   r   r7   r   r  ru   Tr  r:   )rL   r   r   r   r   r  r   r
   r   r  r   )rM   r   r   r  r  r  r  r  rT   r+  rl   rn   r   r=   r  rQ   rQ   rR   test_polyfit_with_masked_NaNsc  s    



4&z,TestPolynomial.test_polyfit_with_masked_NaNsN)r~   r   r   r  r  rQ   rQ   rQ   rR   r  :  s   'r  c                   @   s   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d Zdd Zdd Zdd  Zd!S )"TestArraySetOpsc                 C   s   ddddddg}t |ddd}tt|d t t|d tdddgdddgd t|d dddg t|d ddddddg d S )	Nr:   r7   ru   TZreturn_indexZreturn_inverser   r   rz   )r   r   r   r   r   r   r   rQ   rQ   rR   test_unique_onlistv  s    "z"TestArraySetOps.test_unique_onlistc                 C   s  t ddddddgddddddgd}t|ddd}t|d t ddddgddddgd t|d ddd	dg t|d ddddddg d|_t ddddddgddddddgdd
}t|ddd}t|d t ddddgddddgd t|d ddd	dg t|d ddddddg d S )Nr:   r7   ru   r   r   Tr  r   rz   )rg   r<   
fill_value)r   r   r   r  r   rQ   rQ   rR   test_unique_onmaskedarray  s    $& &z)TestArraySetOps.test_unique_onmaskedarrayc                 C   s   t dddgdd}t|ddd}t|d t dgdgd t|d dg t|d dddg t}t|ddd}t|d t t t|d dg t|d dg d S )Nr:   Tr   r  r   r7   )r   r   r   r
   r   rQ   rQ   rR   test_unique_allmasked  s    z%TestArraySetOps.test_unique_allmaskedc                 C   sr   t tddddddgd}tddddgddddgd}t|}t|| t|d|d t|j|j d S )Nrz   r:   r   r   r   )r   rL   r	   r   r#   r   r  r<   )rM   r   rO   rN   rQ   rQ   rR   test_ediff1d  s    
zTestArraySetOps.test_ediff1dc              	   C   s   t tddddddgd}t|td}tdddddgdddddgd}t|| t|d|d t|j|j t|dddgd}tdddddddgdddddddgd}t|| t|d|d t|j|j d S )	Nrz   r:   r   r   )to_beginr   r7   ru   	r   rL   r	   r#   r
   r   r   r  r<   rM   r   rN   rO   rQ   rQ   rR   test_ediff1d_tobegin  s     
(
z$TestArraySetOps.test_ediff1d_tobeginc              	   C   s   t tddddddgd}t|td}tdddddgdddddgd}t|| t|d|d t|j|j t|dddgd}tdddddddgdddddddgd}t|| t|d|d t|j|j d S )	Nrz   r:   r   r   )to_endr   r7   ru   r  r  rQ   rQ   rR   test_ediff1d_toend  s     
(
z"TestArraySetOps.test_ediff1d_toendc              
   C   s   t tddddddgd}t|ttd}tddddddgddddddgd}t|| t|d|d t|j|j t|dddgtd}tddddddddgddddddddgd}t|| t|d|d t|j|j d S )	Nrz   r:   r   r   r  r  r   r7   ru   r  r  rQ   rQ   rR   test_ediff1d_tobegin_toend  s    $

z*TestArraySetOps.test_ediff1d_tobegin_toendc                 C   s   t d}t|}tddddgddddgd}t|| tt|t t|d|d t|j	|j	 t|t
t
d}tddddddgddddddgd}tt|t t|d|d t|j	|j	 d S )Nrz   r:   r   r   r  )rL   r	   r#   r   r   r   r   r   r  r<   r
   r  rQ   rQ   rR   test_ediff1d_ndarray  s    

$z$TestArraySetOps.test_ediff1d_ndarrayc                 C   sh   t ddddgddddgd}t ddddgddddgd}t||}t dddgdddgd}t|| d S )Nr:   ru   r   r   r   )r   r!   r   )rM   r   r   rN   rO   rQ   rQ   rR   test_intersect1d  s
    
z TestArraySetOps.test_intersect1dc                 C   s  t dddddgdddddgd}t dddd	ddgddddddgd}t||}t|t dd	dg t dddddgdddddgd}dddd	dg}t||}t|t dd	ddgddddgd t dddg}t d
dd	g}t||}tt|t t|dddd	dd
g t ddddgddddgd}t d
dd	dgddddgd}t||}tt|t t|dddd	dd
g tg tg g  d S )Nr:   r7   rz   rc   r   r   r   ru   r   rr   rs   )r   r   r   r   r   r   r   rM   r=   r>   rN   rQ   rQ   rR   test_setxor1d  s&     $
 
"

zTestArraySetOps.test_setxor1dc                 C   s   t ddddg}t dddg}d|d< t||d}tdd	d
ddddddg	dddddddddg	d}tdtd}d|d< d|d< d|d< t||}tt|t	 t
|| t |||j  |j @ }t
|| d S )Nr   r7   ru   r   r:   )r:   r7   r   r   r   r`   r   r   r   r   r   )rg   r<   r7   ru   r   r8   T)r   r   r   )r   r   r:   )r   r7   ru   )rL   r	   r   r   r   r|   r0   r   r   r   r   r<   )rM   r=   r<   r>   ecrT   r   rQ   rQ   rR   	test_isin  s     

zTestArraySetOps.test_isinc                 C   s   t dddddgdddddgd}t dddd	ddgddddddgd}t||}t|d
d
d
dd
g t dddddgdddddgd}t dddgdddgd}t||}t|d
d
dd
d
g tg tg g  d S )Nr:   r7   rz   rc   r   r   r   ru   r   TF)r   r"   r   r   r  rQ   rQ   rR   	test_in1d  s     $
 
zTestArraySetOps.test_in1dc                 C   s   t dddddgdddddgd}t dddd	ddgddddddgd}ttt||t||d
d t dddddgdddddgd}t dddgdddgd}ttt||t||d
d tg tg g d
d d S )Nr:   r7   rz   rc   r   r   r   ru   r   T)invert)r   r   rL   r  r"   r   r  rQ   rQ   rR   test_in1d_invert*  s     $   z TestArraySetOps.test_in1d_invertc           	   	   C   s  t ddddddgddddddgd}t dddd	ddgddddddgd}t||}t dddd	dddgdddddddgd}t|| t dddgdd	dggdddgdddggd}t ddddd	gdddddgd}t ddddd	dgddddddgd}t||}t|| tg tg g  d S )
Nr:   r7   rz   rc   r   r   r   ru   r   )r   r    r   r   )	rM   r=   r>   rN   rO   r   r   Zezr   rQ   rQ   rR   test_union1d6  s    $$
(
, $

zTestArraySetOps.test_union1dc              
   C   s   t ddddddddgddddddddgd}t ddd	d	dddg}t||}t|t ddd
gdddgd td}td}tt||t ddg t g tjg d}tt|g jtj d S )Nrr   rz   r   rc   r:   r7   r   r   ru   r   r`   rs   rt   )r   r   r   r	   rL   Zuint32r9   r  rQ   rQ   rR   test_setdiff1dH  s    ,
zTestArraySetOps.test_setdiff1dc                 C   s<   t dddg}t dddg}tt||t dg d S )Nr=   r>   rT   rn   )rL   r   r   r   r  rQ   rQ   rR   test_setdiff1d_char_arrayU  s    z)TestArraySetOps.test_setdiff1d_char_arrayN)r~   r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rQ   rQ   rQ   rR   r  t  s    		r  c                   @   s   e Zd Zdd Zdd ZdS )TestShapeBasec                 C   sr   t dddgdddgd}t|}t|jd t|jj|jj t|jd t|jj|jj t|jj|jj d S )Nr   r:   r7   r   r[  rW  )r   r   r   r   r<   rg   r  rQ   rQ   rR   test_atleast_2d^  s    zTestShapeBase.test_atleast_2dc                 C   s  t d}t|jd t|jj|j t|jj|j t dd}|D ]0}t|jd t|jj|j t|jj|j qBtd}t|jd t|jj|j t|jj|j tdd}|D ]0}t|jd t|jj|j t|jj|j qtd}t|jd t|jj|j t|jj|j tdd}|D ]2}t|jd t|jj|j t|jj|j q*td}t|jd t|jj|jj d S )Nr   rU   r   rD   r   )r   r   r   r<   rg   r   r   r1   )rM   r>   r=   rQ   rQ   rR   test_shape_scalarh  s<    


zTestShapeBase.test_shape_scalarN)r~   r   r   r  r  rQ   rQ   rQ   rR   r  \  s   
r  c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestNDEnumeratec                 C   s   t dd}t j|td}t||d}ttt |tt| ttt|tt| ttt|tt|dd d S )Nr   )r:   ru   r7   r8   r   Fri   )	rL   r	   r   Z
zeros_liker|   r   r   r  r2   )rM   ZordinaryZ
empty_maskZ	with_maskrQ   rQ   rR   test_ndenumerate_nomasked  s    

z)TestNDEnumerate.test_ndenumerate_nomaskedc                 C   s   t d}t d}t d}ttt|g  ttt|g  ttt|ddtttddtg  ttt|g  ttt|ddtttddtg  d S )NrQ   )d   r  Fr  r  r   )r.   r   r  r2   r  rL   Zndindexr
   )rM   r=   r>   rT   rQ   rQ   rR   test_ndenumerate_allmasked  s    z*TestNDEnumerate.test_ndenumerate_allmaskedc                 C   s   t tddddddgddddgddddggd}dddd	d
g}ttt|| tttt|dd|j t|ddD ]\}}t|| | q~d S )Nr   rU  r:   r   r   )r  rr   ))r7   r   rs   )rV  rt   )rE   r`   )rZ  r   Fr  )	r   rL   r	   r   r   r  r2   r[   r{   )rM   r=   itemsZ
coordinatevaluerQ   rQ   rR   test_ndenumerate_mixedmasked  s     


   z,TestNDEnumerate.test_ndenumerate_mixedmaskedN)r~   r   r   r  r  r  rQ   rQ   rQ   rR   r    s   r  c                   @   s$   e Zd Zdd Zdd Zdd ZdS )	TestStackc                 C   s   t dddgdddgd}t dddgdddgd}t||gdd}t|jd	 t|j|d j t|j|d j t||g}t|j|j t|j|j t||gdd}t|jd
 t|j|d d df j t|j|d d df j d S )Nr   r:   r7   r   rt   rs   rc   r   rZ  ru   r7   r   r3   r   r   r   r<   r4   rg   rM   r=   r>   rT   r   rQ   rQ   rR   test_stack_1d  s    zTestStack.test_stack_1dc                 C   s   t dddgdd}t dddgd	d}t||gdd
}t|jd t|j|d j t|j|d j t||g}t|j|j t|j|j t||gdd
}t|jd t|j|d d df j t|j|d d df j d S )Nr   r:   r7   Tr   rt   rs   rc   Fr   rZ  r  r  r  rQ   rQ   rR   test_stack_masks  s    zTestStack.test_stack_masksc           
      C   s  d}t jdd|}t jdd|}t jdd|t}t jdd|t}t||d}t||d}t||gdd}d| }	t|j|	 t	|j
|d j
 t	|j
|d j
 t||gd	d}|d }	t|j|	 t	|j
|d
 j
 t	|j
|d j
 d}t jdd|}t jdd|}t jdd|t}t jdd|t}t||d}t||d}t||gdd}d| }	t|j|	 t	|j
|d j
 t	|j
|d j
 t||gd	d}|d }	t|j|	 t	|j
|d
 j
 t	|j
|d j
 d S )Nr  r   r`   r7   r   r   r6   r:   r   ).r   ).r:   )ru   r7   r   rz   )rL   r   randintr  r|   r   r3   r   r   r   r<   )
rM   Zshpd1Zd2r   r   Za1r  rT   Zc_shprQ   rQ   rR   test_stack_nd  sD    zTestStack.test_stack_ndN)r~   r   r   r  r  r  rQ   rQ   rQ   rR   r    s   r  )L__doc__rh  r4  r   ZnumpyrL   Znumpy.testingr   r   Znumpy.ma.testutilsr   r   r   r   Znumpy.ma.corer   r	   r
   r   r   r   r   r   r   r   r   Znumpy.ma.extrasr   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/   r0   r1   r2   r3   r4   r5   r   r   r   r   r  r$  r(  rm  r  r  r  r  r  r  rQ   rQ   rQ   rR   <module>   s<   4
  O,F    }Ck: i7&