+
    ,i                         R t ^ RIt^ RIHtHtHt ^RIHt ^ RI	H
t
 ^ RI	Ht ^ RI	Ht ^ RI	Ht ^ RIHt R	 tR
 t ! R R4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      tR# )z9
Unit test for Linear Programming via Simplex Algorithm.
N)assert_assert_allcloseassert_equal)magic_square_remove_redundancy_svd_remove_redundancy_pivot_dense)_remove_redundancy_pivot_sparse_remove_redundancy_id)	csc_arrayc                  D    \         P                  P                  R 4       R# )  N)nprandomseed     N/usr/lib/python3/dist-packages/scipy/optimize/tests/test__remove_redundancy.pysetup_moduler      s    IINN4r   c                ,   V  F.  pV F$  p\         P                  ! W#8H  4      '       g   K#   K+  	   R# 	  V P                  ^ ,          \         P                  P	                  V 4      u;8H  ;'       d#    \         P                  P	                  V4      8H  # u # )zAChecks whether a matrix contains only independent rows of anotherF)r   allshapelinalgmatrix_rank)ABrowArowBs   &&  r   redundancy_removedr       sp    Dvvdl##    771:..q1MMRYY5J5J15MMMMMr   c                      a  ] tR t^(t o 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V tR# )RRCommonTestsc                    ^
^
r!\         P                  P                  W4      p\         P                  P                  V4      pV P                  W44      w  rVrx\	        W54       \	        WF4       \        V^ 4       R# )
   N)r   r   randrrr   r   	selfmnA0b0A1b1statusmessages	   &        r   test_no_redundancy RRCommonTests.test_no_redundancy)   sY    21YY^^A!YY^^A"&''"/VQr   c                    \         P                  ! ^4      p^ VR&   \         P                  P                  ^4      pV P	                  W4      w  r4rV\        V^4       R# )   N   NNN)r   eyer   r%   r&   r   r(   r   br-   r.   r/   r0   s   &      r   test_infeasible_zero_row&RRCommonTests.test_infeasible_zero_row2   sF    FF1I$IINN1"&''!-VQr   c                   \         P                  ! ^4      p^ VR&   \         P                  P                  ^4      p^ V^&   V P	                  W4      w  r4rV\        V^ 4       \        W1^ ^.R3,          4       \        WB^ ^.,          4       R# )r4   r7   Nr5   )r   r8   r   r%   r&   r   r   r9   s   &      r   test_remove_zero_row"RRCommonTests.test_remove_zero_row9   ss    FF1I$IINN1!"&''!-VQq!faiL)q!fI&r   c                    ^^
r!\         P                  P                  W4      p\         P                  P                  V4      pV P                  W44      w  rVrx\	        V^4       R# )   Nr   r   r%   r&   r   r'   s	   &        r   test_infeasible_m_gt_n$RRCommonTests.test_infeasible_m_gt_nC   sI    21YY^^A!YY^^A"&''"/VQr   c                    ^
^
r!\         P                  P                  W4      p\         P                  P                  V4      p^VR,          ,          VR&   V P                  W44      w  rVrx\	        V^4       R# )r$   N)r7   r7   rB   r'   s	   &        r   test_infeasible_m_eq_n$RRCommonTests.test_infeasible_m_eq_nJ   sZ    21YY^^A!YY^^A5	M5	"&''"/VQr   c                ,   ^	^
r!\         P                  P                  W4      p\         P                  P                  V4      p\         P                  ! V^,
          4      P	                  VRR 4      VR&   V P                  W44      w  rVrx\        V^4       R# 	   NrH   rG   )r   r   r%   arangedotr&   r   r'   s	   &        r   test_infeasible_m_lt_n$RRCommonTests.test_infeasible_m_lt_nR   sp    "1YY^^A!YY^^AIIa!e$((CR15	"&''"/VQr   c                (   \         P                  P                  R 4       ^^
r!\         P                  P                  W4      p\         P                  P                  V4      p\         P                  P                  VRV1R3,          VRV 4      pW2R1R3,          P                  V4      WBR% V P                  W44      w  rgr\        V^ 4       \        VP                  ^ ,          V4       \        \         P                  P                  V4      V4       R# )i  Nr7   )r   r   r   r%   r   solverO   r&   r   r   r   )
r(   r)   r*   r+   r,   xr-   r.   r/   r0   s
   &         r   test_m_gt_nRRCommonTests.test_m_gt_nZ   s    
		t21YY^^A!YY^^AIIOOBrr1uIr"1v.BEq!2"&''"/VQRXXa[!$RYY**2.2r   c                    ^^
r!\         P                  ! W34      p^VR&   \         P                  ! V4      pV P                  W44      w  rVrx\	        V^ 4       \        WSR,          4       \        Wd^ ,          4       R# )rA   N)r7       ):rX   r6   Nr7   )r   zerosonesr&   r   r   r'   s	   &        r   test_m_gt_n_rank_deficient(RRCommonTests.test_m_gt_n_rank_deficientf   sc    21XXqf4WWQZ"&''"/VQvJ'qE"r   c                   ^	^
r!\         P                  P                  W4      p\         P                  P                  V4      p\         P                  ! V^,
          4      P	                  VRR 4      VR&   \         P                  ! V^,
          4      P	                  VRR 4      VR&   V P                  W44      w  rVrx\        V^ 4       \        VP                  ^ ,          ^4       \        \         P                  P                  V4      ^4       R# rL   )
r   r   r%   rN   rO   r&   r   r   r   r   r'   s	   &        r   test_m_lt_n_rank_deficient(RRCommonTests.test_m_lt_n_rank_deficientp   s    "1YY^^A!YY^^AIIa!e$((CR15	1q5!%%b"g.2"&''"/VQRXXa[!$RYY**2.2r   c                   \         P                  ! R4      p^ VR&   ^ VR&   RVR&   ^ VR&   ^ VR&   \         P                  ! VP                  ^ ,          4      pV P	                  W4      w  r4rV\        \        W14      4       \        V^ 4       R# )	   N)ra   ra   )rX   :Nr4   N)r6   r4   NNrH   )rb   :NN   )r4   :Nrc   N)   :rc   NN)r   rZ   rY   r   r&   r   r    r   r9   s   &      r   test_dense1RRCommonTests.test_dense1{   s|    GGFO%%'
%%HHQWWQZ "&''!-"2)*VQr   c                    \         P                  ! ^4      p^VR&   ^VR&   \         P                  ! VP                  ^ ,          4      pV P	                  W4      w  r4rV\        \        W14      4       \        V^ 4       R# )ra   NrF   rH   rG   )r   r8   rY   r   r&   r   r    r   r9   s   &      r   test_dense2RRCommonTests.test_dense2   sa    FF1I&	%HHQWWQZ "&''!-"2)*VQr   c                F   \         P                  ! ^4      p^VR&   ^VR&   \         P                  P                  VP                  ^ ,          4      p\         P
                  ! VRR 4      VR&   V P                  W4      w  r4rV\        \        W14      4       \        V^ 4       R# )ra   NrH   rh   rG   )
r   r8   r   r%   r   sumr&   r   r    r   r9   s   &      r   test_dense3RRCommonTests.test_dense3   s|    FF1I&	%IINN1771:&q"v""&''!-"2)*VQr   c                .   \         P                  P                  R 4       ^^r!Rp\         P                  P                  W4      p^ V\         P                  P                  W4      V8  &   \         P                  P                  V4      p\         P                  ! VP                  ^ ,          4      pV P                  WF4      w  rxr\        V	^ 4       \        VP                  ^ ,          V4       \        \         P                  P                  V4      V4       R# )i  g?N
r   r   r   r%   r   r   rY   r   r&   r   r(   r)   r*   pr   rankr:   r-   r.   r/   r0   s   &          r   test_m_gt_n_sparse RRCommonTests.test_m_gt_n_sparse   s    
		t11IINN1 &'"))..

"#yy$$Q'HHQWWQZ "&''!-VQRXXa[$'RYY**2.5r   c                .   \         P                  P                  R 4       ^^2r!Rp\         P                  P                  W4      p^ V\         P                  P                  W4      V8  &   \         P                  P                  V4      p\         P                  ! VP                  ^ ,          4      pV P                  WF4      w  rxr\        V	^ 4       \        VP                  ^ ,          V4       \        \         P                  P                  V4      V4       R# )r   g?Nrp   rq   s   &          r   test_m_lt_n_sparse RRCommonTests.test_m_lt_n_sparse   s    
		t21IINN1 &'"))..

"#yy$$Q'HHQWWQZ "&''!-VQRXXa[$'RYY**2.5r   c                .   \         P                  P                  R 4       ^d^dr!Rp\         P                  P                  W4      p^ V\         P                  P                  W4      V8  &   \         P                  P                  V4      p\         P                  ! VP                  ^ ,          4      pV P                  WF4      w  rxr\        V	^ 4       \        VP                  ^ ,          V4       \        \         P                  P                  V4      V4       R# )r   g{Gz?Nrp   rq   s   &          r   test_m_eq_n_sparse RRCommonTests.test_m_eq_n_sparse   s    
		tC1IINN1 &'"))..

"#yy$$Q'HHQWWQZ "&''!-VQRXXa[$'RYY**2.5r   c                    \        ^4      w  rr4pV P                  W4      w  rgr\        V^ 4       \        VP                  ^ ,          ^4       \        \        P
                  P                  V4      ^4       R# )r4   Nr   r&   r   r   r   r   r   
r(   r   r:   cnumbers_r-   r.   r/   r0   s
   &         r   test_magic_squareRRCommonTests.test_magic_square   Y    *1oa!"&''!-VQRXXa["%RYY**2.3r   c                    \        ^4      w  rr4pV P                  W4      w  rgr\        V^ 4       \        VP                  ^ ,          ^'4       \        \        P
                  P                  V4      ^'4       R# )rd   Nr}   r~   s
   &         r   test_magic_square2 RRCommonTests.test_magic_square2   r   r   r   N)__name__
__module____qualname____firstlineno__r1   r;   r>   rC   rI   rP   rU   r[   r^   re   ri   rm   rt   rw   rz   r   r   __static_attributes____classdictcell____classdict__s   @r   r"   r"   (   s_       '   
3#	3   66644 4r   r"   c                   &   a  ] tR t^t o R tRtV tR# )	TestRRSVDc                    \        W4      # Nr   r(   r   r:   s   &&&r   r&   TestRRSVD.rr   s    %a++r   r   Nr   r   r   r   r&   r   r   r   s   @r   r   r      s     , ,r   r   c                   &   a  ] tR t^t o R tRtV tR# )TestRRPivotDensec                    \        W4      # r   r   r   s   &&&r   r&   TestRRPivotDense.rr   s    -a33r   r   Nr   r   s   @r   r   r      s     4 4r   r   c                   &   a  ] tR t^t o R tRtV tR# )TestRRIDc                    \        W4      # r   r   r   s   &&&r   r&   TestRRID.rr   s    $Q**r   r   Nr   r   s   @r   r   r      s     + +r   r   c                   &   a  ] tR t^t o R tRtV tR# )TestRRPivotSparsec                \    \        \        V4      V4      pVw  rErgVP                  4       WVV3# r   )r
   r   toarray)r(   r   r:   rr_resr-   r.   r/   r0   s   &&&     r   r&   TestRRPivotSparse.rr   s/    01qA"(zz|R00r   r   Nr   r   s   @r   r   r      s     1 1r   r   )__doc__numpyr   numpy.testingr   r   r   test_linprogr   !scipy.optimize._remove_redundancyr   r	   r
   r   scipy.sparser   r   r    r"   r   r   r   r   r   r   r   <module>r      su     
 ' D L M C "	Nf4 f4R, ,
4} 4
+} +
1 1r   