o
    0c"                     @   s   d dl Zd dl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mZ d dlmZ d dlmZ G dd deejZG d	d
 d
ZG dd dZG dd dZdS )    N)assert_warns)assert_assert_equalassert_raisesassert_array_equal)masked_arraymasked_valuesmaskedallequalMaskTypegetmaskMaskedArraynomasklogaddhypotdividemr_)picklec                   @   s,   e Zd ZefddZdd Zedd ZdS )MMatrixc                 C   s   t |}tj| ||d}|S )N)datamask)npmatrixr   __new__)clsr   r   mat_data r   ^/var/www/html/gps/gps/lib/python3.10/site-packages/numpy/matrixlib/tests/test_masked_matrix.pyr      s   
zMMatrix.__new__c                 C   s   t j| | t| | d S N)r   r   __array_finalize__r   )selfobjr   r   r    r"      s   zMMatrix.__array_finalize__c                 C   s   |  t}d|_|S )NF)viewr   _sharedmask)r#   _viewr   r   r    _series   s   
zMMatrix._seriesN)__name__
__module____qualname__r   r   r"   propertyr(   r   r   r   r    r      s
    r   c                   @   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 )TestMaskedMatrixc                 C   s  t g dg dg}t|g dg dgd}t|g dg dgd}t|}t| t| tt|d t|d u  t|d |d k t|d tu  t|d |d  t|d	d
d f |d	d
d f  t|d d df |d d df  t|d d  |d d   t|d
d  |d
d   d|d< d|d< t|| d|d	d
d f< d|d	d
d f< t|| t|d< t|| t|d	d
d f< t|| |d	d d f |d	d d f< t|d< tt	t
|t g dg dg tg dg d|d
d d f< tt	t
|d
 tg d tt	t
|d
 tg d tg dg d|d
d d f< tt	t
|d
 tg d tt	|d
 tg d t t dd }t|d}t|| tt	tg dtd|j td|j d S )N         )   r1   r0   r/   r   r   )r   r/   r   r   r/   r   )r/   r/   )r   r0   r   r/   r0   	   c   )r   r/   )r/   r/   r            ?      @)r   r   r   r/   r   dtype)r   r   r   strreprr   typer	   r   r
   r   arrayaranger   r   r   
fill_value)r#   x1x2x3x4r   r   r    test_matrix_indexing    sP   ""



$

z%TestMaskedMatrix.test_matrix_indexingc                 C   sz   t tttdg dd d}tdtjd D ]!}ttj||d}t	|j
|j
 t	|| tt|jtj qd S )N
   )r/   r   r/   r   r   r0   r4   r/   )protocol)r   r   r   listranger   HIGHEST_PROTOCOLloadsdumpsr   _maskr   
isinstancer   )r#   aproto	a_pickledr   r   r    test_pickling_subbaseclassL   s   "
z+TestMaskedMatrix.test_pickling_subbaseclassc                 C   s   t tddgddggtdd}t|jddjd	 t|jddjd
 t|jddddgg t|jdddgdgg d S )Nr/   r0   r1   r2   )r0   r0   r4   r   )axis)r/   r0   )r0   r/   g       @r:   g      ?g      @)r   r   r   zerosr   countshapemean)r#   mr   r   r    test_count_mean_with_matrixU   s
   $z,TestMaskedMatrix.test_count_mean_with_matrixc                 C   sb  t tg dgg dd}t|jd d t|jd t tt|jdd |dddf k t tg dgg dd}t g dg dd|_t tg dgg dd}t|| t tg dgg dd}|j}|g d	 |d d < t|| d
|d< t ttddd}|j}|d d }t|j	t
ddgg t|jt
ddgg d S )Nr.   )r   r   r/   r4   r/   r0   r   )r1   r0   r/   r3   )r0   r/   r   r6   r9   g        F)r   r   r   r   flatr	   r   alleyer   r@   r   )r#   testcontroltestflatrQ   bb01r   r   r    	test_flat_   s$   (

zTestMaskedMatrix.test_flatc                 C   st  t g dg dg dg}t |}t jg dg dg dgt jd}t||d}|d	k}|d	k }t|   t|  t|d
t g d t|dt g dj	 t|d
t g d t|dt g dj	 t|   t|  t|d
t g d t|dt g dj	 t|d
t g d t|dt g dj	 d S )N)gp=
ף?gp=
ף?g?)gQ?gQ?g)\(?)gףp=
?gףp=
?gffffff?)TFF)FFF)TTFr;   r4   g      ?r   )FFTr/   )TTT)
r   r@   r   bool_r   r   r]   anyr   T)r#   xXrZ   mXmXbigmXsmallr   r   r    test_allany_onmatricesx   s4   


 z'TestMaskedMatrix.test_allany_onmatricesc                 C   s`   t tg dg dd}| }t|| tt|tj t|d< | }t|g dg d S )N)r/   r0   r1   r2   )r   r   r   r   r4   )r   r   )r0   r1   r2   )r   r   r   
compressedr   r   rP   r	   )r#   rQ   rb   r   r   r    test_compressed   s   
z TestMaskedMatrix.test_compressedc                 C   sD   t tg dg dgd}| }t|jd t|jj|j d S )N)r/   r0   r1   r2   r8   r   r/   r   r   r   r4   )r/   r8   )r   r   r   ravelr   rX   rO   )r#   rQ   aravelr   r   r    
test_ravel   s   zTestMaskedMatrix.test_ravelc                 C   s   t ttdtjd}t|}t|dtfdtfgd}d|j	d< |
tdftj}t|| tt|tj tt|t  d S )NrH   rQ   rb   r;   r5   r   r0   )rJ   zipr   rA   randomrandr@   r   floatr   r%   r   r   r   rP   r   )r#   iteratorr   rQ   r_   r   r   r    	test_view   s   


zTestMaskedMatrix.test_viewN)r)   r*   r+   rG   rT   r[   rd   rm   ro   rs   ry   r   r   r   r    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 )TestSubclassingc                 C   s,   t jddd}t|g dd}||f| _d S )Nr8   rw   r;   rp   r4   )r   rA   r   r   r#   rh   mxr   r   r    setup_method   s   zTestSubclassing.setup_methodc                 C   s    | j \}}tt|jtj d S r!   )r   r   rP   r   r   r   r{   r   r   r    test_maskedarray_subclassing   s   
z,TestSubclassing.test_maskedarray_subclassingc                 C   sb   | j \}}tjdd ttt|t tt|t| W d    d S 1 s*w   Y  d S )Nignore)r   )r   r   errstater   rP   r   r   r   r{   r   r   r    test_masked_unary_operations   s
   
"z,TestSubclassing.test_masked_unary_operationsc                 C   s   | j \}}ttt||t ttt||t tt||||  ttt||jtj t	t
 ttt||t W d    n1 sIw   Y  ttt||t ttt||t d S r!   )r   r   rP   r   r   r   r   r   r   r   DeprecationWarningouterr   r{   r   r   r    test_masked_binary_operations   s   

z-TestSubclassing.test_masked_binary_operationsc                 C   s`   | j \}}t|j  |jd}ttt||t ttt||t tt||t|| d S )Nr4   )	r   r   	__array__r   r   rP   r   r   r   )r#   rh   r|   xmxr   r   r    test_masked_binary_operations2   s
   
z.TestSubclassing.test_masked_binary_operations2N)r)   r*   r+   r}   r~   r   r   r   r   r   r   r    rz      s    rz   c                   @   s   e Zd Zdd Zdd ZdS )TestConcatenatorc                 C   s   t tjjdd  d S )Nc                   S   s   t d S )Nz
1, 2; 3, 4r   r   r   r   r    <lambda>   s    z6TestConcatenator.test_matrix_builder.<locals>.<lambda>)r   r   maMAError)r#   r   r   r    test_matrix_builder   s   z$TestConcatenator.test_matrix_builderc                 C   sP   t d }tjtjd }t|| tt|t| tt|jt|j d S )N)rr/   r0   r1   )	r   r   r   r@   r_r   r   r?   r   )r#   actualexpectedr   r   r    test_matrix   s
   
zTestConcatenator.test_matrixN)r)   r*   r+   r   r   r   r   r   r    r      s    r   )numpyr   numpy.testingr   numpy.ma.testutilsr   r   r   r   numpy.ma.corer   r   r	   r
   r   r   r   r   r   r   r   r   numpy.ma.extrasr   numpy.compatr   r   r   r-   rz   r   r   r   r   r    <module>   s    8 *