+
    ib.                         R t ^ RIt^ RIt^ RIt^ RIt^ RIHtHtH	t	H
t
HtHtHt R tR tR tR tR tR tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR t  ! R R4      t!R t"R t#R# )zTests of interaction of matrix with other parts of numpy.

Note that tests with MaskedArray and linalg are done in separate files.
N)assert_assert_almost_equalassert_array_almost_equalassert_array_equalassert_equalassert_raisesassert_raises_regexc                     \         P                  ! ^^.^^..4      p \        \        V . ROR3,          \         P                  4      4       \         P                  ! \         P
                  ! ^24      P                  ^^
4      4      p\        VR\         P                  ! R4      3,          VR,          P                  4       R# )   :NNNN   NN)    r
   r   )r   r   )
npmatrixr   
isinstanceasmatrixarangereshaper   arrayT)mxs     o/Users/mibo/.openclaw/workspace/.venv-ak/lib/python3.14/site-packages/numpy/matrixlib/tests/test_interaction.pytest_fancy_indexingr      s    
 			Aq6Aq6"#AJqA		23 	BIIbM))!R01A2rxx|#$aikk2    c                      ^ ^.p ^^.p\         P                  ! W .4      p\         P                  P                  P	                  W V4      p\        \        V\         P                  4      4       R# )r   N)r   r   
polynomial	polyutils	mapdomainr   r   )dom1dom2r   ress       r   test_polynomial_mapdomainr#   %   sU     q6Dq6D
		4,A
--
!
!
+
+AT
:CJsBII&'r   c                      \         P                  ! . RO.4      p \         P                  ! V RR7      p\         P                  ! . RO.4      p\        W4       \	        \        V4      \         P                  J 4       R# r   Naxis)r   r
   r   r   r
   r   )r   r   sortr   r   typeaactualexpecteds      r   test_sort_matrix_noner/   /   sO    
		9+AWWQT"Fyy)%H"DNbii'(r   c                      \         P                  ! . RO.4      p \         P                  ! V ^RR7      p\         P                  ! . RO.4      p\        W4       \	        \        V4      \         P                  J 4       R# r%   )r   r   	partitionr   r   r*   r+   s      r   test_partition_matrix_noner2   8   sS     			9+A\\!QT*Fyy)%H"DNbii'(r   c                     \         P                  ! ^^.\        R7      p \         P                  ! ^^..\        R7      p\        \         P                  ! V ^4      V4       \        \         P                  ! ^V 4      V4       R# r
   dtypeN)r   r   objectr   dotarrdesireds     r   %test_dot_scalar_and_matrix_of_objectsr<   B   sV     ))QF&
)Cii!Q/GQ)3)r   c                     \         P                  R ,          \         P                  R,          ,           R,            F  p \         P                  ! ^V R7      R,          p\         P                  ! ^^.^^..V R7      p\         P                  ! ^^.^	^..V R7      p\	        \         P
                  ! W!4      V4       \	        \         P
                  ! W4      V4       K  	  R# )
AllIntegerAllFloat?r5   N )r   	typecodesr   r   r   inner)dtscar:   r;   s       r   test_inner_scalar_and_matrixrF   K   s    ll<(2<<
+CCcIIhhq#B'ii!Q!Q(3))aVaW-R8RXXc'1RXXc'1 Jr   c                     \         P                  ! ^^.\        R7      p \         P                  ! ^^..\        R7      p\        \         P                  ! V ^4      V4       \        \         P                  ! ^V 4      V4       R# r4   )r   r   r7   r   rC   r9   s     r   'test_inner_scalar_and_matrix_of_objectsrH   U   sX     ))QF&
)Cii!Q/G#q!7+!S!7+r   c            
         \         P                  ! ^^.^^..4      p \         P                  ! ^4      P                  ^^4      P                  p\         P
                  ! WR.. R.R.RR..4      p\        \        VP                  ^,          4      \         P                  J 4       \        \        VP                  ^,          4      \         P                  J4       \        VP                  ^,          P                  R4       \         P                  ! ^4      P                  ^^^4      p\        \        \         P
                  WR.. R.R.RR..4       \         P
                  ! WR.. R.R.. RO.4      p\        \        VP                  ^,          4      \         P                  J 4       \        \        VP                  ^,          4      \         P                  J4       \        VP                  ^,          P                  R4       R# )r
   Nreadonly	writeonlyallocate)r   r   )rK   rL   
no_subtype)r
   r   r   )r   r   r   r   r   nditerr   r*   operandsndarrayr   shaper   RuntimeError)r,   bis      r   !test_iter_allocate_output_subtyperU   ^   s    			Aq6Aq6"#A
		!Q"$$A
		1,<*Z/HI	KADA299,-DArzz12A$$f- 			!Q1%A,		A$<<*Z/HIK 			1,<*:<	=A DA2::-.DAryy01A$$i0r   c                  ^   \         P                  ! ^^.^^..4      p \         P                  \         P                  \         P                  3 F]  pV! V 4      p\        \        V4      \         P                  J 4       V! V RR7      p\        \        V4      \         P                  J4       K_  	  R# )r
   F)subokN)r   r   
zeros_like	ones_like
empty_liker   r*   )r,   like_functionrS   cs       r   r[   r[   y   s{    
		Aq6Aq6"#AbmmC!Q299$%!5)Qryy() Dr   c                     \         P                  ! . R	O. R
O.RR7      p V P                  RRRR7      p\        WJ 4       V P                  RRR7      p\	        W4       \	        \        V4      \         P                  4       V P                  RRRR7      p\	        W4       \        WJ4       \        \        V4      \         P                  J4       R# )r   f4r5   TF)rW   copyi4)r_   Nr(   )         )r   r   astyper   r   r*   r,   rS   s     r   test_array_astyperf      s     			9i(5A	T.AAFO 	
E"Aa"))$ 	
U/ALDG299$%r   c                      \         P                  ! ^^.^^..4      p \        \        R\         P                  W .4       R# )r
   zshape too large to be a matrixN)r   r   r   
ValueErrorstack)r   s    r   
test_stackrj      s7     			Aq6Aq6"#A
$D1&*r   c                     \         P                  ! ^^.\        R7      p \         P                  ! ^^..\        R7      p\        \         P                  ! V ^4      V4       \        \         P                  ! ^V 4      V4       R# r4   )r   r   r7   r   multiplyr9   s     r   test_object_scalar_multiplyrm      sX     ))QF&
)Cii!Q/GS!$g.Q$g.r   c            
         \         P                  ! \         P                  ! ^4      4      p \         P                  \         P                  3 F  pV! V ^ R7      p\        \        V\         P                  4      4       \        VP                  R8H  4       V! V ^R7      p\        \        V\         P                  4      4       \        VP                  R8H  4       V! V 4      p\        \         P                  ! V4      4       K  	  \         P                  V ^&   \         P                  \         P                  3 EF}  p\        P                  ! RR7      ;_uu_ 4       p\        P                  ! R4       V! V ^ R7      p\        \        V\         P                  4      4       \        \         P                  ! \         P                  ! V4      4      '       * 4       \        \        V4      ^ 8H  4       RRR4       \        P                  ! RR7      ;_uu_ 4       p\        P                  ! R4       V! V ^R7      p\        \        V\         P                  4      4       \        \         P                  ! VR	,          4      ;'       dM    \         P                  ! VR
,          4      '       * ;'       d#    \         P                  ! VR,          4      '       * 4       \        \        V4      ^8H  R4       \        \!        V^ ,          P"                  \$        4      4       RRR4       \        P                  ! RR7      ;_uu_ 4       p\        P                  ! R4       V! V 4      p\        \         P                  ! V4      4       \        V\         P                  8g  4       \        \        V4      ^ 8H  4       RRR4       EK  	  R#   + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     EK  ; i)ra   r&   T)recordalwaysNzno warning raisedr
   ra   ra   r
   )r
   r   )r   r   )r   r   )r   r   eyenanminnanmaxr   r   rQ   isscalarnanwarningscatch_warningssimplefilteranyisnanlen
issubclasscategoryRuntimeWarning)matfr"   ws       r   test_nanfunctions_matricesr      s    ))BFF1I
Cii#!n
3		*+		V#$!n
3		*+		V#$fC ! $ VVCFii#$$D11Q!!(+Ca.CJsBII./rxx}--.CFaK  2 $$D11Q!!(+Ca.CJsBII./BHHSY' 0 0T0C,C 0 0HHSY//1CFaK!45Jqt}}n=> 2 $$D11Q!!(+C&CBKK$%C266M"CFaK  21# $111 21 211s.   BN:BO*A)O:A1O!:OO!O3c                     \         P                  ! \         P                  ! ^4      4      p \         P                  \         P                  \         P
                  \         P                  \         P                  \         P                  \         P                  3 F  pV! V ^ R7      p\        \        V\         P                  4      4       \        VP                  R8H  4       V! V ^R7      p\        \        V\         P                  4      4       \        VP                  R8H  4       V! V 4      p\        \         P                  ! V4      4       K  	  \         P                  \         P                  3 F  pV! V ^ R7      p\        \        V\         P                  4      4       \        VP                  R8H  4       V! V ^R7      p\        \        V\         P                  4      4       \        VP                  R8H  4       V! V 4      p\        \        V\         P                  4      4       \        VP                  R8H  4       K  	  R# )ra   r&   Nrq   rr   )ra   ra   )r
   	   )r   r   rs   	nanargmin	nanargmaxnansumnanprodnanmeannanvarnanstdr   r   rQ   rv   	nancumsum
nancumprod)r   r   r"   s      r   "test_nanfunctions_matrices_generalr      sn    ))BFF1I
CllBLL"))RZZjj"))RYY0!n
3		*+		V#$!n
3		*+		V#$fC !0 \\2==(!n
3		*+		V#$!n
3		*+		V#$f
3		*+		Z'( )r   c                     \         P                  ! \         P                  P                  ^^4      4      p \	        V P                  ^ 4      \         P                  ! V ^ 4      4       \         P                  ! ^^.^^..4      p\         P                  ! ^^.^^..4      p\         P                  ! V^ VR7      p\        \        V4      \         P                  4       \        VRR..4       R# )rc   )r'   weightsg      @Ng
@)	r   r   randomrandr   meanaverager   r*   )yr,   r   rs       r   test_average_matrixr      s    
		"))..A&'Aqvvay"**Q"23
		Aq6Aq6"#A
		Aq6Aq6"#A


11a(Aa"))$c8_%&r   c                  <   \         P                  ! ^ ^4      p \         P                  ! R^ 4      p\         P                  ! V 4      p\         P                  ! V4      p\         P                  ! W4      p\         P                  ! W#P                  4      p\        WT4       R# )r   N)r   linspacer   r8   r   r   )r   r   mxmyr   mrs         r   test_dot_matrixr      se     	AqA
BA	1B	1B
qA	DD	Br   c                  2   \        \        P                  ! \        P                  ! ^4      4      \        P                  4      '       g   Q h\        \        P                  ! \        P                  ! ^4      ^R7      \        P                  4      '       g   Q hR# )r
   )to_beginN)r   r   ediff1dr   rA   r   r   test_ediff1d_matrixr     sT    bjj1.		::::bjj1:BIIFFFFr   c                     R  p \         P                  ! ^ ^.^^..4      p\         P                  ! ^ ^.^^..4      p\         P                  ! V ^ V4      p\        \	        V\         P                  4      4       \        W24       \         P                  ! V ^V4      p\        \	        V\         P                  4      4       \        W24       R# )c                     V ^,          # )r   rA   )rows   &r   double,test_apply_along_axis_matrix.<locals>.double  s    Qwr   N)r   r   apply_along_axisr   r   r   )r   r   r.   results       r   test_apply_along_axis_matrixr     s     			Aq6Aq6"#Ayy1a&1a&)*H  A.FJvryy)*v(  A.FJvryy)*v(r   c                     \         P                  ! ^^.4      p \         P                  ! V 4      p\        \	        \         P
                  ! W 4      4      \         P                  4       \        \	        \         P
                  ! W4      4      \         P                  4       \        \	        \         P
                  ! W4      4      \         P                  4       \        \	        \         P
                  ! W4      4      \         P                  4       R# )r   N)r   onesr   r   r*   kronrP   r   )r,   r   s     r   test_kron_matrixr     s    
AA
AAbggam$bjj1bggam$bii0bggam$bii0bggam$bii0r   c                   2   a  ] tR tRt o R tR tR tRtV tR# )TestConcatenatorMatrixi)  c                  aa ^^.o^^.o\         P                  RSS3,          p\         P                  RSS3,          p\        \        V4      \         P                  4       \        \        V4      \         P                  4       \        \         P
                  ! V4      . RO.4       \        \         P
                  ! V4      ^.^.^.^..4       \        \        VV3R l4       R# )r
   r   r\   c                  8   < \         P                  R S S3,          # )rc)r   r_re   s   r   <lambda>4TestConcatenatorMatrix.test_matrix.<locals>.<lambda>8  s    "%%a
*;r   N)r
   r   ra   rb   )r   r   r   r*   r   r   r   rh   )selfab_rab_cr,   rS   s   &  @@r   test_matrix"TestConcatenatorMatrix.test_matrix+  s    FFuuS!QYuuS!QYT$Z+T$Z+RXXd^l^4RXXd^qcA3aS%9:j";<r   c                    \         P                  R ^^.^3,          p\        \        V4      \         P                  4       \        \         P
                  ! V4      . RO.4       R# )r   N)r
   r   ra   )r   r   r   r*   r   r   )r   r   s   & r   test_matrix_scalar)TestConcatenatorMatrix.test_matrix_scalar:  s@    EE#1vq.!T!Wbii(RXXa[9+.r   c                r   \         P                  ! ^.4      p\         P                  ! ^.4      p\         P                  ! ^.4      p\         P                  ! ^.4      p\         P                  R,          p\         P                  ! W.W4..4      p\	        WV4       \	        \        V4      \        V4      4       R# )r
   z
a, b; c, dN)r   r   r   bmatr   r*   )r   r,   rS   r\   dr-   r.   s   &      r   test_matrix_builder*TestConcatenatorMatrix.test_matrix_builder?  s}    HHaSMHHaSMHHaSMHHaSM|$77QFQF+,V&T&\4>2r   rA   N)	__name__
__module____qualname____firstlineno__r   r   r   __static_attributes____classdictcell__)__classdict__s   @r   r   r   )  s     =/
	3 	3r   r   c            	      ^   \         P                  ! \        4      ;_uu_ 4       p \        \        P
                  ! ^^.4      \        P                  ! ^^.4      4       RRR4       \        X P                  4      p\        P                  ! R4      p\        W4       R#   + '       g   i     LH; i)r
   Nzw
    Arrays are not equal

    (shapes (2,), (1, 2) mismatch)
     ACTUAL: array([1, 2])
     DESIRED: matrix([[1, 2]]))pytestraisesAssertionErrorr   r   r   r   strvaluetextwrapdedent)exc_infomsgmsg_references      r   %test_array_equal_error_message_matrixr   K  sp    	~	&	&(RXXq!f%ryy!Q'89 
'
hnn
COO %" #M $ 
'	&s   9BB,	c                  J   \         P                  ! R R..4      p \         P                  ! R \         P                  ..4      p\         P                  ! R \         P                  ) ..4      p\         P                  ! \         P                  \         P                  ..4      p\         P                  ! R R.\         P                  \         P                  ..4      p\        \
        3 F=  pWW#V3 F1  pV! Wf4       \         P                  ! V4      pV! Wv4       V! Wg4       K3  	  K?  	  R# )g      ?g       @N)r   r   rw   infr   r   r   )m1m2m3m4m5assert_funcr   r,   s           r   test_array_almost_equal_matrixr   Z  s     
RH:	B	RL>	"B	R"&&M?	#B	RVVRVV$%	&B	RHrvvrvv./	0B02EE#AA	 $ Fr   )$__doc__r   rx   r   numpyr   numpy.testingr   r   r   r   r   r   r   r   r#   r/   r2   r<   rF   rH   rU   r[   rf   rj   rm   r   r   r   r   r   r   r   r   r   r   rA   r   r   <module>r      s         3())*2,16*&&*/&!R)8
'	G)&13 3D%r   