
    >qjf3              
           d Z ddlZddlZddl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mZmZ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ddd	d
ddd
d	Z-d Z.ej^                  ja                  d       G d d             Z1 G d de1      Z2 G d de1      Z3 G d de1      Z4ej^                  jj                   G d de1             Z6ej^                  jj                   G d de1             Z7ej^                  ja                  d       G d d             Z8y) z2 Test functions involving 64bit or 32bit indexing     N)
	bsr_array	coo_array	csc_array	csr_array	dia_array
bsr_matrix
coo_matrix
csc_matrix
csr_matrix
dia_matrix   )TestBSRTestCOOTestCSCTestCSRTestDIATestDOKTestLILTestBSRMatrixTestCOOMatrixTestCSCMatrixTestCSRMatrixTestDIAMatrixTestDOKMatrixTestLILMatrixwith_64bit_maxval_limitz%expm for 64-bit indices not availablez)linsolve for 64-bit indices not availableztest implemented in base classz%test actually requires 64-bit to workztest verifies int32 indexesztest verifies int64 indexesz!test produces deprecation warning)		test_expmtest_inv
test_solvetest_scalar_idx_dtypetest_large_dimensions_reshapetest_constructor_smallcoltest_constructor_largecoltest_sparse_format_conversionstest_tocoo_tocsr_tocsc_gh19245c              #     K   | dk(  rt         t        t        t        t        g}nT| dk(  rt
        t        g}nB| dk(  rt        t        t        t        t        g}n!| dk(  rt        t        g}nt        d| d      |D ]  }t        t!        |            D ]  }t#        ||      }|j%                  d      s!t#        |dd	      r/g }t&        j)                  |      }|r/|j+                  t,        j.                  j1                  |
             t#        |dg       }|D ]"  }|j2                  dv s|j+                  |       $ t-        j4                  |||         yw)a  Yield all tests for all formats

    This is more than testing get_index_dtype. It allows checking whether upcasting
    or downcasting the index dtypes affects test results. The approach used here
    does not try to figure out which tests might fail due to 32/64-bit issues.
    We just run them all.
    So, each test method in that uses cases_64bit reruns most of the test suite!
    sparraysparray-extraspmatrixspmatrix-extrazparameter sp_api=z is not validtest_slowFreason
pytestmark)skipifskipxfailxslow)marksN)_TestBSR_TestCOO_TestCSC_TestCSR_TestDIA_TestDOK_TestLIL_TestBSRMatrix_TestCOOMatrix_TestCSCMatrix_TestCSRMatrix_TestDIAMatrix_TestDOKMatrix_TestLILMatrix
ValueErrorsorteddirgetattr
startswith
SKIP_TESTSgetappendpytestmarkr1   nameparam)	sp_apiTEST_CLASSESclsmethod_namemethodr4   msgmarkersrL   s	            \/opt/rentech/trading_bot/.venv/lib/python3.12/site-packages/scipy/sparse/tests/test_64bit.pycases_64bitrW   +   sG      (HhI	?	"
 !(+	:	&&8	#	#&7-fYm<== B!#c(+ 	BKS+.F&&w/6 nn[1LL!1!1!1!=>!&,;# +Dyy$HHT*+ ll35AA	BBs   B/E2E A(E)2Ezfails in parallelr-   c                       e Zd Zd Zy)RunAll64Bitc                 8    t        di |d        } |||       y )Nc                      |        }t        |d      r|j                          	  t        ||              t        |d      r|j                          y y # t        |d      r|j                          w w xY w)Nsetup_methodteardown_method)hasattrr\   rF   r]   )rQ   rR   instances      rV   checkz,RunAll64Bit._check_resiliency.<locals>.check^   sl    uHx0%%'/.+.08%67,,. 878%67,,. 8s   A A3 )r   )selfrQ   rR   kwr`   s        rV   _check_resiliencyzRunAll64Bit._check_resiliencyZ   s*     
!	&2	&	/ 
'	/ 	c;    N)__name__
__module____qualname__rd   ra   re   rV   rY   rY   X   s     re   rY   c            	          e Zd Zej                  j                  d e ed                  d        Zej                  j                  d e ed                  d        Z	ej                  j                  d e ed                  d        Z
ej                  j                  d      ej                  j                  d e ed                  d               Zy)	Test64BitArraycls,method_namer'   c                 ,    | j                  ||d       y N
   maxval_limitrd   rb   rQ   rR   s      rV   test_resiliency_limit_10z'Test64BitArray.test_resiliency_limit_10o       sKbAre   c                 H    | j                  ||t        j                         y Nfixed_dtyperd   npint32rr   s      rV   test_resiliency_all_32z%Test64BitArray.test_resiliency_all_32s       sKRXXFre   c                 H    | j                  ||t        j                         y rv   rd   rz   int64rr   s      rV   test_resiliency_all_64z%Test64BitArray.test_resiliency_all_64w   r}   re      c                 (    | j                  ||       y Nrq   rr   s      rV   test_resiliency_randomz%Test64BitArray.test_resiliency_random{   s     	sK0re   Nrf   rg   rh   rK   rL   parametrizelistrW   rs   r|   r   	fail_slowr   ra   re   rV   rj   rj   l   s     [[.[5K0LMB NB [[.[5K0LMG NG [[.[5K0LMG NG [[1[[.[5K0LM1 N 1re   rj   c            	           e Zd Zej                  j                  d      ej                  j                  d e ed                  d               Z	y)Test64BitMatrix   rk   r)   c                 ,    | j                  ||d       y NT)assert_32bitrq   rr   s      rV   
test_no_64zTest64BitMatrix.test_no_64        	sKdCre   N)
rf   rg   rh   rK   rL   r   r   r   rW   r   ra   re   rV   r   r      sJ    [[1[[.[5L0MND O Dre   r   c            	          e Zd Zej                  j                  d e ed                  d        Zej                  j                  d e ed                  d        Z	ej                  j                  d e ed                  d        Z
ej                  j                  d      ej                  j                  d e ed                  d               Zy)	Test64BitMatrixSameAsArrayrk   r)   c                 ,    | j                  ||d       y rm   rq   rr   s      rV   rs   z3Test64BitMatrixSameAsArray.test_resiliency_limit_10   rt   re   c                 H    | j                  ||t        j                         y rv   ry   rr   s      rV   r|   z1Test64BitMatrixSameAsArray.test_resiliency_all_32   r}   re   c                 H    | j                  ||t        j                         y rv   r   rr   s      rV   r   z1Test64BitMatrixSameAsArray.test_resiliency_all_64   r}   re   r   c                 (    | j                  ||       y r   rq   rr   s      rV   r   z1Test64BitMatrixSameAsArray.test_resiliency_random        	sK0re   Nr   ra   re   rV   r   r      s     [[.[5L0MNB OB [[.[5L0MNG OG [[.[5L0MNG OG [[1[[.[5L0MN1 O 1re   r   c            	          e Zd Zej                  j                  d e ed                  d        Zej                  j                  d e ed                  d        Z	ej                  j                  d e ed                  d        Z
ej                  j                  d      ej                  j                  d e ed                  d               Zy)	Test64BitArrayExtrark   r(   c                 ,    | j                  ||d       y rm   rq   rr   s      rV   rs   z,Test64BitArrayExtra.test_resiliency_limit_10   rt   re   c                 H    | j                  ||t        j                         y rv   ry   rr   s      rV   r|   z*Test64BitArrayExtra.test_resiliency_all_32   r}   re   c                 H    | j                  ||t        j                         y rv   r   rr   s      rV   r   z*Test64BitArrayExtra.test_resiliency_all_64   r}   re   r   c                 (    | j                  ||       y r   rq   rr   s      rV   r   z*Test64BitArrayExtra.test_resiliency_random   r   re   Nr   ra   re   rV   r   r      s     [[.[5Q0RSB TB [[.[5Q0RSG TG [[.[5Q0RSG TG [[1[[.[5Q0RS1 T 1re   r   c            	       P   e Zd Zej                  j                  d      ej                  j                  d e ed                  d               Z	ej                  j                  d e ed                  d        Z
ej                  j                  d e ed                  d        Zej                  j                  d e ed                  d        Zej                  j                  d      ej                  j                  d e ed                  d	               Zy
)Test64BitMatrixExtrar   rk   r*   c                 ,    | j                  ||d       y r   rq   rr   s      rV   r   zTest64BitMatrixExtra.test_no_64   r   re   c                 ,    | j                  ||d       y rm   rq   rr   s      rV   rs   z-Test64BitMatrixExtra.test_resiliency_limit_10   rt   re   c                 H    | j                  ||t        j                         y rv   ry   rr   s      rV   r|   z+Test64BitMatrixExtra.test_resiliency_all_32   r}   re   c                 H    | j                  ||t        j                         y rv   r   rr   s      rV   r   z+Test64BitMatrixExtra.test_resiliency_all_64   r}   re   r   c                 (    | j                  ||       y r   rq   rr   s      rV   r   z+Test64BitMatrixExtra.test_resiliency_random   r   re   N)rf   rg   rh   rK   rL   r   r   r   rW   r   rs   r|   r   r   ra   re   rV   r   r      s2    [[1[[.[AQ5R0STD U D
 [[.[AQ5R0STB UB [[.[AQ5R0STG UG [[.[AQ5R0STG UG [[1[[.[AQ5R0ST1 U 1re   r   z%Fails in parallel for unknown reasonsc            
       <    e Zd Zeeeeeee	e
eeg
Zd Zd Zd Zd Zy)Test64BitToolsc                    t        j                  |      }|j                  dv r4|j                  j                  |k(  xr |j                  j                  |k(  S |j                  dk(  r4|j
                  j                  |k(  xr |j                  j                  |k(  S |j                  dk(  r|j                  j                  |k(  S t        d|d      )N)csccsrbsrcoodiazmatrix z has no integer indices)	rz   dtypeformatindicesindptrrowcoloffsetsrC   )rb   mr   s      rV   _compare_index_dtypez#Test64BitTools._compare_index_dtype   s    88,,IIOOu,K188>>U3JKXXEEKK5(Dquu{{e/CDXXIIOOu,-wqe+BCDDre   c                 `     t        d       fd       } j                  D ]
  } ||        y )Nrn   ro   c                 &    | t         j                  j                  dd            }j                  |t         j                        sJ  | t         j                  j                  dd            }j                  |t         j
                        sJ y )Nrn   r      )rz   randomrandr   r{   r   )mat_clsr   rb   s     rV   r`   z9Test64BitTools.test_decorator_maxval_limit.<locals>.check   si    		r1-.A,,Q999		r1-.A,,Q999re   r   MAT_CLASSESrb   r`   r   s   `  rV   test_decorator_maxval_limitz*Test64BitTools.test_decorator_maxval_limit   s:     
!b	1	: 
2	: '' 	G'N	re   c                 `     t        d       fd       } j                  D ]
  } ||        y )NT)r   c                 ,   d}d}t        d      D ]w  } | t        j                  j                  dd            }|xs  j	                  |t        j
                        }|xs  j	                  |t        j                        }|st|sw y  t        d      )NFd   	   z#both 32 and 64 bit indices not seen)rangerz   r   r   r   r{   r   AssertionError)r   seen_32seen_64kr   rb   s        rV   r`   z:Test64BitTools.test_decorator_maxval_random.<locals>.check   s    GG3Z LBIINN1a01!KT%>%>q"((%K!KT%>%>q"((%KwL %%JKKre   r   r   s   `  rV   test_decorator_maxval_randomz+Test64BitTools.test_decorator_maxval_random   s<     
!	-
	L 
.
	L '' 	G'N	re   c                 6   t        t        j                  d      d        }t        t        j                        d        } |t        t        t
                |t        t        t
                |t        t        t                |t        t        t               y )Nr   )rx   downcast_maxvalc                 0    | ddgddgddgg      }t        j                  t        |j                  d       t        j                  t        |j                  d        |g d	g d
g      }t        j                  t        |j                  d       t        j                  t        |j                  d        |g d	g dg      }t        j                  t        |j                  d       d|_        t        j                  t        |j                         y Nr   r         r      )axisr   )r   r   r   )r   r   r   )r   r   r   F)rK   raisesr   count_nonzerosumhas_canonical_formatsum_duplicatescsc_containercsr_containercoo_containeras       rV   check_limitedz8Test64BitTools.test_downcast_intp.<locals>.check_limited  s     1v1v1v67AMM.!//BMM.!%%a8y)45AMM.!//BMM.!%%a8y)45AMM.!//B%*A"MM.!*:*:;re   rw   c                 @    | ddgddgddgg      }|j                  d       |j                  d        |g d	g d
g      }|j                  d       |j                  d        |g d	g dg      }|j                  d       d|_        |j                          y r   )r   r   r   r   r   s       rV   check_unlimitedz:Test64BitTools.test_downcast_intp.<locals>.check_unlimited  s     1v1v1v67AOOO#EEqEMy)45AOOO#EEqEMy)45AOOO#%*A"re   )	r   rz   r   r   r   r   r
   r   r	   )rb   r   r   s      rV   test_downcast_intpz!Test64BitTools.test_downcast_intp  sq     
!RXXq	I	< 
J	< 
!RXX	6	 
7	 	iI6	9i8j*j9
J
;re   N)rf   rg   rh   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   ra   re   rV   r   r      s6     	J
J
9iIK
	E&)<re   r   )9__doc__rK   numpyrz   scipy.sparser   r   r   r   r   r   r	   r
   r   r   	test_baser   r5   r   r6   r   r7   r   r8   r   r9   r   r:   r   r;   r   r<   r   r=   r   r>   r   r?   r   r@   r   rA   r   rB   r   rH   rW   rL   thread_unsaferY   rj   r   r   r3   r   r   r   ra   re   rV   <module>r      s-   8        * 9;==%L!>!>&I&C

*BZ "56    7 &1[ 1*Dk D1 1, 1+ 1 1. 1; 1 18 "IJ[< [< K[<re   