+
    0iu)                     \   ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIHtHtH	t	 ^ RI
HtHtHtHtHtHt ^ RIHt ^ RIHt ^ RIt^ RIHt R tR tR	 tR
 t]P8                  P:                  ]P8                  P=                  R4      R 4       4       t]P8                  PA                  ] PB                  PE                  R4      ;'       d*    ]PF                  ! ]PH                  4      PJ                  ^8  '       * RR7       ! R R4      4       t&]P8                  PO                  RR7      R 4       t(R t)R t*R# )    N)assert_equalassert_assert_allclose)_sparsetools
coo_matrix
csr_matrix
csc_matrix
bsr_matrix
dia_matrix)supported_dtypes)check_free_memory)raisesc                0    V ^,           R,          ^,
          # )z.
Wrap an integer to the interval [-128, 127].
    )ns   &a/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/sparse/tests/test_sparsetools.pyint_to_int8r      s     Gs?S      c                  B    \        \        \        P                  4       R # N)assert_raisesMemoryErrorr   test_throw_errorr   r   r   test_exceptionr      s    +|<<=r   c                    aaaa	 ^
p ^do	^o\        \        P                  ! SS.4      4      o. o ! VVVV	3R lR\        P                  4      p\        V 4       Uu. uF	  q!! 4       NK  	  ppV F  pVP                  4        K  	  V F  pVP                  4        K  	  S F3  p\        \        P                  ! VP                  4       ^8H  4      4       K5  	  R# u upi )
   c                   4   <a  ] tR t^'t o VVVV3R ltRtV tR# )test_threads.<locals>.Workerc                b  < SP                  4       p\        S4       F}  p\        P                  ! SSSP                  SP
                  SP                  SP                  SP
                  SP                  VP                  VP
                  VP                  4       K  	  SP                  V4       R # r   )copyranger   csr_plus_csrindptrindicesdataappend)selfbjabresr   niters   &  r   run test_threads.<locals>.Worker.run(   su    A5\))!Q*+((AIIqvv*+((AIIqvv*+((AIIqvvG "
 KKNr   r   N)__name__
__module____qualname____firstlineno__r.   __static_attributes____classdictcell__)__classdict__r+   r,   r   r-   s   @r   Workerr   '   s     	 	r   r7   N)r   npones	threadingThreadr"   startjoinr   alltoarray)
nthreadsr7   _threadsthreadr)   r+   r,   r   r-   s
         @@@@r   test_threadsrD      s     HE
A277Aq6?#AD !!  "'x1AvxG1   qyy{a'()  2s   Cc                      \          Fj  p \        P                  ! ^^.^^..4      P                  V 4      p\	        WR7      p\        VP                  ^ 4      P                  4       VR,          4       Kl  	  R# )   dtypeN):NNN:NrF   N)r   r8   arrayastyper   r   getcolr?   )rH   adr+   s      r   !test_regression_std_vector_dtypesrM   ;   s_     "XX1v1v&'..u5r' 	QXXa[((*BuI6 "r   z!Can't create large array for testc                     \         P                  ! \         P                  4      P                  ^,           p \	        ^	V ,          R,          R,           4       \         P
                  ! V \         P                  R7      p\         P
                  ! V \         P                  R7      p\         P
                  ! V \         P                  R7      p^VR&   \        W1V33RRR7      pVP                  4       p\        V^..4       R# )	rF       .Ag      ?rG   F)shaper!   N)rF   rF   )
r8   iinfoint32maxr   zerosint8r   r?   r   )nnzrowcolr&   sds         r   test_nnz_overflowr\   F   s    
 ((288

 
 1
$CyC'#-34 ((3bhh
'C
((3bhh
'C88Crww'DDHD*%V%@A			AAur   linuxztest requires 64-bit Linux)reasonc            
         a  ] tR t^[t o RtRtR tR t]P                  P                  ^4      R 4       t]P                  P                  R 4       t]P                  P                  R 4       t]P                  ! R]P                  P                   R	7      ]P                  ! R
]P                  P                   R	7      RRR]P                  ! R]P                  P                   R	7      .t]P                  P                  ]P                  P%                  R]4      R 4       4       t]P                  P                  ]P                  P%                  R]4      R 4       4       tR tR tR tR tR tR tRtV tR# )TestInt32Overflowz
Some of the sparsetools routines use dense 2D matrices whose
total size is not bounded by the nnz of the sparse matrix. These
routines used to suffer from int32 wraparounds; here, we try to
check that the wraparounds don't occur any more.
iP  c                L   V P                   ^,          \        P                  ! \        P                  4      P                  8  g   Q h \        \        P                  P                  RR4      4      p\        RV,          4       R#   \         d    \        P                  p L1i ; i)   PYTEST_XDIST_WORKER_COUNT1i  N)r   r8   rR   rS   rT   intosenvironget
ValueErrorinfr   )r(   parallel_counts   & r   setup_methodTestInt32Overflow.setup_methodi   ss    vvqy288BHH-11111	$ 0KS!QRN 	$/0  	$VVN	$s   )B B#"B#c                0    \         P                  ! 4        R # r   )gccollect)r(   s   &r   teardown_method!TestInt32Overflow.teardown_methodu   s    


r   c                   V P                   p\        P                  ! ^ V^,
          .4      p\        P                  ! ^ V^,
          .4      p\        P                  ! ^^.\        P                  R7      p\	        WBV334      pVP                  4       p\        VR,          ^4       \        VR,          ^4       ?\        P                  ! 4        R# r   rG   Nr   r   )rQ   rQ   )	r   r8   rI   rV   r   todenser   ro   rp   )r(   r   ir*   r&   mrs   &      r   test_coo_todense"TestInt32Overflow.test_coo_todensex   s     FFHHa1XHHa1XxxAbgg.!f~&IIKQsVQQuXq!


r   c                Z   V P                   p\        P                  ! ^ V^,
          .4      p\        P                  ! ^ V^,
          .4      p\        P                  ! ^^.\        P                  R7      p\	        WBV334      p\        P
                  ! W3\        P                  R7      p\        \        \        3 FX  pV! V4      pVP                  V4      p	\        V	R,          ^4       \        V	R,          ^4       ?	\        P                  ! 4        KZ  	  ?\        P                  ! 4        R# rt   )r   r8   rI   rV   r   r9   r   r	   r
   dotr   ro   rp   )
r(   r   rw   r*   r&   rx   r)   sptypem2ry   s
   &         r   test_matvecsTestInt32Overflow.test_matvecs   s     FFHHa1XHHa1XxxAbgg.!f~&GGQF"''*!:z:FBq	A3#51%JJL ; 


r   c                   V P                   p\        P                  ! W3\        P                  R 7      p\        P                  ! V4      p\        W#3W3R7      p\        P                  ! VP                  ^,          \        P                  R 7      pVP                  V4      p\        V^ ,          \        V4      4       ?????\        P                  ! 4        R# )rG   )rP   N)r   r8   r9   rV   aranger   rP   r}   r   r   ro   rp   )r(   r   r&   offsetsrx   vry   s   &      r   test_dia_matvec!TestInt32Overflow.test_dia_matvec   s     FFwwvRWW-))A,qf5GGAGGAJbgg.EE!HQqT;q>*'1a


r   matmat)marksmatvecsmatvecdiagonalsort_indices	transposeopc                   a  V 3R  lp\         P                  ! 4         \        S RV,           4      ! V4       \         P                  ! 4        R#   \         P                  ! 4        i ; i)c                  6  < SP                   p \        P                  ! ^W 3\        P                  R7      p\        P                  ! ^ ^.\        P
                  R7      p\        P                  ! ^ .\        P
                  R7      p\        WV3W 3RR7      p???V# rF   rG   F)	blocksizer!   )r   r8   r9   rV   rI   rS   r
   r   r&   r$   r%   rx   r(   s        r   
get_matrix6TestInt32Overflow.test_bsr_1_block.<locals>.get_matrix   ss    A77Aq9BGG4DXXq!fBHH5Fhhs"((3GD62qf5QAfgHr   _check_bsr_Nro   rp   getattrr(   r   r   s   f& r   test_bsr_1_block"TestInt32Overflow.test_bsr_1_block   s?    	 	

	D-",-j9JJLBJJL   A A%c                   a  V 3R  lp\         P                  ! 4         \        S RV,           4      ! V4       \         P                  ! 4        R#   \         P                  ! 4        i ; i)c                  6  < SP                   p \        P                  ! W ^3\        P                  R7      p\        P                  ! ^ V .\        P
                  R7      p\        P                  ! V \        P
                  R7      p\        WV3V ^3RR7      p???V# r   )r   r8   r9   rV   rI   rS   r   r
   r   s        r   r   6TestInt32Overflow.test_bsr_n_block.<locals>.get_matrix   ss    A77A!9BGG4DXXq!fBHH5Fii2GD62q!f5QAfgHr   r   Nr   r   s   f& r   test_bsr_n_block"TestInt32Overflow.test_bsr_n_block   s?    	 	

	D-",-j9JJLBJJLr   c                    V! 4       pV P                   pVP                  \        P                  ! V^3\        P                  R7      4      p\        VR,          \        V4      4       R# )rb   rG   Nru   r   r}   r8   r9   rV   r   r   r(   rx   r   ry   s   &&  r   _check_bsr_matvecs$TestInt32Overflow._check_bsr_matvecs   sG    CFF EE"''1a&01QtWk!n-r   c                    V! 4       pV P                   pVP                  \        P                  ! V3\        P                  R 7      4      p\        V^ ,          \        V4      4       R# )rG   Nr   r   s   &&  r   _check_bsr_matvec#TestInt32Overflow._check_bsr_matvec   sE    CFF EE"''1$bgg./QqT;q>*r   c                    V! 4       pV P                   pVP                  4       p\        V\        P                  ! V4      4       R # r   )r   r   r   r8   r9   r   s   &&  r   _check_bsr_diagonal%TestInt32Overflow._check_bsr_diagonal   s1    CFF JJLQ
#r   c                4    V! 4       pVP                  4        R # r   )r   r(   rx   s   &&r   _check_bsr_sort_indices)TestInt32Overflow._check_bsr_sort_indices   s    C	r   c                4    V! 4       pVP                  4        R # r   )r   r   s   &&r   _check_bsr_transpose&TestInt32Overflow._check_bsr_transpose   s    C	r   c                   V! 4       pV P                   p\        \        P                  ! V^3\        P                  R7      VP
                  ^,          ^3R7      pVP                  V4       ?\        \        P                  ! ^V3\        P                  R7      ^VP
                  ^ ,          3R7      pVP                  V4       R# )rb   rG   )r   N)r   r
   r8   r9   rV   r   r}   )r(   rx   r   r   s   &&  r   _check_bsr_matmat#TestInt32Overflow._check_bsr_matmat  s    CFF Abgg61;;q>STBUV	b	 Abgg61akkRSnBUV
q	r   r   N)r0   r1   r2   r3   __doc__r   rl   rq   pytestmark	fail_slowrz   slowr   r   paramxslow_bsr_opsparametrizer   r   r   r   r   r   r   r   r4   r5   )r6   s   @r   r`   r`   [   sf    
 	A
1 [[1 $ [[ * [[
 
 XV[[->->?Yfkk.?.?@[0A0ABDH [[[[T8, - ( [[[[T8, - *.+$

 r   r`   z/64-bit indices in sparse matrices not availablec                     R p V ^,          \         P                  ! \         P                  4      P                  8  g   Q h\	        V ^,          ^,          R,          4       \         P
                  ! V 3\         P                  R7      p\         P                  ! V ^,           \         P                  R7      p\         P                  ! V \         P                  R7      p\        WV34      pVP                  p\        \        VP                  V4       R# )l   4s	j rO   rG   N)r8   rR   int64rT   r   r9   rV   r   rU   r   Tr   RuntimeErrorr}   )r   r&   r$   r%   r+   r)   s         r   test_csr_matmat_int64_overflowr     s    Aa4"((288$((((( a7ma'#-. 77A4rww'DYYqs"((+Fhhq)GD6*+A	A,q)r   c                     \        \        P                  \        P                  R ,          .^^..\        R7      p \        P                  ! R	R
.\        R7      p\
         EFm  p\
         EF^  pRV: RV: R2p\        P                  ! V\        P                  4      '       d!   V P                  4       P                  V4      pM)V P                  P                  4       P                  V4      p\        P                  ! V\        P                  4      '       d!   VP                  4       P                  V4      pMQ\        P                  ! RR7      ;_uu_ 4        VP                  P                  4       P                  V4      pRRR4       V\        P                  8X  d   V\        P                  8X  gj   \        P                  ! R\        P                  R7      p\        \        \         P"                  ^^VP$                  VP&                  VP(                  XV4	       \        P                  ! V\        P                  4      '       d,   \        P                  ! V\        P                  4      '       dW   \        P                  ! V\        P                  4      '       g   \        P                  ! V\        P                  4      '       dj   \        P                  ! R\        P*                  R7      p\        \        \         P"                  ^^VP$                  VP&                  VP(                  XV4	       \        P                  ! R\        P,                  ! W#4      R7      p\         P"                  ! ^^VP$                  VP&                  VP(                  XV4       \/        V\        P0                  ! VP3                  4       V4      VR7       EKa  	  EKp  	  R#   + '       g   i     EL\; i)y              ?rG   (z, )ignore)invalidN)err_msgy      p@      ?l        )rb   )r   r8   picomplexrI   r   
issubdtypecomplexfloatingr!   rJ   realerrstatebool_rU   r   ri   r   
csr_matvecr$   r%   r&   float64result_typer   r}   r?   )a0b0a_dtypeb_dtypemsgr+   r)   cs           r   test_upcastr   $  sv   	beeRUU2X&A/w	?B	65/	1B##''Gg[7+Q/C}}Wb&8&899GGI$$W-GGLLN))'2}}Wb&8&899GGI$$W-[[22 --g6A 3
 rxx'Grxx,?HHT2j,*A*AAHHaiiAG w(:(:;;]]7B,>,>??]]7B,>,>??w(:(:;;HHT4j,*A*AAHHaiiAG R^^G%EFA##Aq!((AIIqvvq!LArvvaiik15sCC? ( $ 322s   *O	O$c                  N   \         P                  ! R4      p . ROp\        V P                  R4      V3R4      p\        V P                  R4      V3R4      p\         P                  ! ^4      p\        VP                  V4      . RO4       \        VP                  V4      . RO4       R# )   z<f8z>f8N)r      )rQ   r   rF   )r   r   )rF   r         )r8   r9   r   rJ   r   r   r}   )r[   r   r+   r)   r   s        r   test_endiannessr   K  sw    
AGAHHUOW-v6AAHHUOW-v6A
		!AAEE!Hl+AEE!Hl+r   )+sysrf   ro   r:   numpyr8   numpy.testingr   r   r   scipy.sparser   r   r   r	   r
   r   scipy.sparse._sputilsr   scipy._lib._testutilsr   r   r   r   r   r   rD   rM   r   r   xfail_on_32bitr\   skipifplatform
startswithrH   intpitemsizer`   skipr   r   r   r   r   r   <module>r      s   
 	 	   @ @2 2 2 3  *!>*>7 ?@ A & 		 	 	)	M	Mbhhrww.?.H.HA.MN'  p p	pf JK* L*"$DN	,r   