
    qKg"                         d dl Z 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  G d deej2                        Z G d d	      Z G d
 d      Z G d d      Zy)    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_c                   ,    e Zd ZefdZd Zed        Zy)MMatrixc                 `    t        j                  |      }t        j                  | ||      }|S )N)datamask)npmatrixr   __new__)clsr   r   mat_datas        l/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numpy/matrixlib/tests/test_masked_matrix.pyr   zMMatrix.__new__   s(    iio##Cc=    c                 p    t         j                  j                  | |       t        j                  | |       y N)r   r   __array_finalize__r   )selfobjs     r!   r%   zMMatrix.__array_finalize__   s)    
		$$T3/&&tS1r"   c                 >    | j                  t              }d|_        |S )NF)viewr   _sharedmask)r&   _views     r!   _serieszMMatrix._series   s    		+&!r"   N)__name__
__module____qualname__r   r   r%   propertyr,    r"   r!   r   r      s#     & 

  r"   r   c                   <    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
y	)
TestMaskedMatrixc           
      V   t        j                  g dg dg      }t        |g dg dg      }t        |g dg dg      }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        j                  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        j                  t        j                  d      dz        }t        |d      }t        ||       t        t        t        g dt              |j                               t        d|j                          y )N         )   r8   r7   r6   r   r   )r   r6   r   r   r6   r   )r6   r6   )r   r7   r   r6   r7   	   c   )r   r6   )r6   r6   r            ?      @)r   r   r   r6   r   dtype)r   r   r   strreprr   typer
   r   r   r   arrayaranger	   r   r   
fill_value)r&   x1x2x3x4s        r!   test_matrix_indexingz%TestMaskedMatrix.test_matrix_indexing!   s   YY	9-."Iy#9:"Iy#9:"BRRX$r$x.014BtH$%4F"#RXr$x(R12Y1ab5	*R1Xr!Q$x(RUBqE"RVRV$44R1ab5	1ab5	R4R1ab5	Rad81a44bhh	9/E&FGH	951a4Qi)@ABAi)@AB	951a4Ai)@ABAY 789YYryy|c)*2s#RoXF" 	#S"--(r"   c           	         t        t        j                  t        t	        d                  g ddz        }t	        dt
        j                  dz         D ]  }t        j                  t        j                  ||            }t        |j                  |j                         t        ||       t        t        |j                  t        j                                y )N
   )r6   r   r6   r   r   r7   r;   r6   )protocol)r   r   r   listrangepickleHIGHEST_PROTOCOLloadsdumpsr   _maskr   
isinstancer    )r&   aproto	a_pickleds       r!   test_pickling_subbaseclassz+TestMaskedMatrix.test_pickling_subbaseclassM   s    4b	?3/A:MN1f559:EV\\!e%DEI!''2A&Jy		:;	 ;r"   c                    t        t        j                  ddgddgg      t        j                  d            }t	        |j                  d      j                  d	       t	        |j                  d      j                  d
       t	        |j                  d      ddgg       t	        |j                  d      dgdgg       y )Nr6   r7   r8   r9   )r7   r7   r;   r   )axis)r6   r7   )r7   r6   g       @rA   g      ?g      @)r   r   r   zerosr   countshapemean)r&   ms     r!   test_count_mean_with_matrixz,TestMaskedMatrix.test_count_mean_with_matrixV   s    QFQF#34288F;KLQWW!W_**F3QWW!W_**F3 	QVVV^r2hZ0QVVV^secU^4r"   c           	         t        t        j                  g dg      g d      }t        |j                  d   d       t        |j                  d   t
               t        t        j                  |j                  dd |dddf   k(               t        t        j                  g dg      g d      }t        g dg d      |_        t        t        j                  g dg      g d      }t        ||       t        t        j                  g dg      g d      }|j                  }|g d	   |d d  t        ||       d
|d<   t        t        j                  t        j                  d            d      }|j                  }|d d }t        |j                  t        j                  ddgg             t        |j                  t        j                  ddgg             y )Nr5   )r   r   r6   r;   r6   r7   r   )r8   r7   r6   r:   )r7   r6   r   r=   r@   g        F)r   r   r   r   flatr
   r   alleyer   rG   r   )r&   testcontroltestflatrZ   bb01s          r!   	test_flatzTestMaskedMatrix.test_flat`   s^    BIIyk2CTYYq\1%TYYq\6*tyy1~a1f567BIIyk2C ;	ryy)5IFT7#BIIyk2C99y)T7#266!9-A6FFeSXXrxx"b
34SXXrxx%(89:r"   c                    t        j                  g dg dg dg      }t        j                  |      }t        j                  g dg dg dgt         j                        }t	        ||      }|d	kD  }|d	k  }t        |j                                 t        |j                                t        |j                  d
      t        j                  g d             t        |j                  d      t        j                  g d      j                         t        |j                  d
      t        j                  g d             t        |j                  d      t        j                  g d      j                         t        |j                                 t        |j                                t        |j                  d
      t        j                  g d             t        |j                  d      t        j                  g d      j                         t        |j                  d
      t        j                  g d             t        |j                  d      t        j                  g d      j                         y )N)gp=
ף?gp=
ף?g?)gQ?gQ?g)\(?)gףp=
?gףp=
?gffffff?)TFF)FFF)TTFrB   r;   g      ?r   )FFTr6   )TTT)
r   rG   r   boolr   r   rh   anyr   T)r&   xXrd   mXmXbigmXsmalls          r!   test_allany_onmatricesz'TestMaskedMatrix.test_allany_onmatricesy   s   HH(((* + IIaLHH*+)+24''; !!$c8EIIK 		UYYq\299-A#BCUYYq\299-A#B#D#DEUYYq\299-A#BCUYYq\299-?#@#B#BCGKKM!"W[[^RYY/B%CDW[[^RYY/D%E%G%GHW[[^RYY/B%CDW[[^RYY/B%C%E%EFr"   c                    t        t        j                  g d      g d      }|j                         }t	        ||       t        t        |t        j                               t        |d<   |j                         }t	        |g dg       y )N)r6   r7   r8   r9   )r   r   r   r   r;   )r   r   )r7   r8   r9   )r   r   r   
compressedr   r   rY   r
   )r&   rZ   rm   s      r!   test_compressedz TestMaskedMatrix.test_compressed   s_    <0|DLLNQ
1bii()$LLNQ$r"   c                     t        t        j                  g d      g dg      }|j                         }t	        |j
                  d       t	        |j                  j
                  |j
                         y )N)r6   r7   r8   r9   r?   r   r6   r   r   r   r;   )r6   r?   )r   r   r   ravelr   rb   rX   )r&   rZ   aravels      r!   
test_ravelzTestMaskedMatrix.test_ravel   sK    ?3?:KLV\\6*V\\''1r"   c                    t        t        t        j                  d      t        j                  j                  d                  }t        j                  |      }t        |dt        fdt        fg      }d|j                  d<   |j                  t        dft        j                        }t        ||       t        t        |t        j                               t        t        |t                      y )NrP   rZ   rm   rB   r<   r   r7   )rR   zipr   rH   randomrandrG   r   floatr   r)   r   r   r   rY   r   )r&   iteratorr   rZ   rj   s        r!   	test_viewzTestMaskedMatrix.test_view   s    BIIbM299>>"+=>?xx!3,e)EFq	vvuaj")),T4 
4+,Jt[112r"   N)r-   r.   r/   rN   r]   re   ro   ry   r|   r   r   r1   r"   r!   r3   r3       s,    *)X<5;2G4%2	3r"   r3   c                   *    e Zd Zd Zd Zd Zd Zd Zy)TestSubclassingc                 b    t        j                  dd      }t        |g d      }||f| _        y )Nr?   r   rB   r~   r;   )r   rH   r   r   r&   rt   mxs      r!   setup_methodzTestSubclassing.setup_method   s)    IIaw'Q_-G	r"   c                 |    | j                   \  }}t        t        |j                  t        j
                               y r$   )r   r   rY   r    r   r   r   s      r!   test_maskedarray_subclassingz,TestSubclassing.test_maskedarray_subclassing   s&    ))B
288RYY/0r"   c                    | j                   \  }}t        j                  d      5  t        t	        t        |      t                     t        t        |      t        j
                  |             d d d        y # 1 sw Y   y xY w)Nignore)r   )r   r   errstater   rY   r   r   r   r   s      r!   test_masked_unary_operationsz,TestSubclassing.test_masked_unary_operations   sP    ))B[[)Js2w01Q+ *))s   AA::Bc           	      |   | j                   \  }}t        t        t        ||      t                     t        t        t        ||      t                     t        t        ||      ||z          t        t        t        ||      j                  t        j                               t        t              5  t        t        t        j                  ||      t                     d d d        t        t        t        ||      t                     t        t        t        ||      t                     y # 1 sw Y   PxY wr$   )r   r   rY   r   r   r   r    r   r   r   DeprecationWarningouterr   r   s      r!   test_masked_binary_operationsz-TestSubclassing.test_masked_binary_operations   s    ))B
3r2;01
3r1:w/0SQZA&
3r2;,,bii89,-JsyyR0':; .
5R='23
5Q<12 .-s   5.D22D;c                 L   | j                   \  }}t        |j                   j                         |j                        }t	        t        t        ||      t                     t	        t        t        ||      t                     t        t        ||      t        ||             y )Nr;   )	r   r   	__array__r   r   rY   r   r   r   )r&   rt   r   xmxs       r!   test_masked_binary_operations2z.TestSubclassing.test_masked_binary_operations2   sm    ))B277,,.RWW=
6"b>734
6"a='23VB^VC%56r"   N)r-   r.   r/   r   r   r   r   r   r1   r"   r!   r   r      s    
1
,37r"   r   c                       e Zd Zd Zd Zy)TestConcatenatorc                 N    t        t        j                  j                  d        y )Nc                      t         d   S )Nz
1, 2; 3, 4r   r1   r"   r!   <lambda>z6TestConcatenator.test_matrix_builder.<locals>.<lambda>   s	    S->r"   )r   r   maMAError)r&   s    r!   test_matrix_builderz$TestConcatenator.test_matrix_builder   s    beemm%>?r"   c                 .   t         d   }t        j                  j                  t        j                  d         }t        ||       t        t        |      t        |             t        t        |j                        t        |j                               y )N)rr6   r7   r8   )	r   r   r   rG   r_r   r   rF   r   )r&   actualexpecteds      r!   test_matrixzTestConcatenator.test_matrix   sc     \"55;;ruu\2368, 	T&\4>2T&++&X]](;<r"   N)r-   r.   r/   r   r   r1   r"   r!   r   r      s    @
=r"   r   )rT   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   r   r   r3   r   r   r1   r"   r!   <module>r      se      &4 44 4 4 4  k299 &K3 K3\(7 (7T= =r"   