L if@ldZddlZddlmZddlZddlmZddlm Z m Z m Z m Z mZddlmZGddZy) z'unit tests for sparse utility functionsN) assert_equal)raises)_sputils csr_array bsr_array dia_array coo_array)matrixceZdZdZdZdZdZdZdZdZ dZ d Z e jjd eegd Zd Zd ZdZe jjdgddgddgddggddggdgdgdgdgdgddgdgddgdgdgdgddgdggddgdgdgd d!gd"gd#d$gd$gd%d$gd$gd#d%gd$gdd$gd$gdd#gd#gdd%gd%gdd&gd&gd&d$gd$gd&d%gd$gd'd$gd$gdd$gd$gdd&gd#gd'd%gd%gd'd#gd#gdd#gd#gdd%gd%gd'd(gd(gd)d*gd*gdgd+zdgdgd,zdgdgd+zdgd-Ze jjd.d(d/gd0dgd)d0ggd1d2d3gd4d2gd5d6ggd7dgd+zd(gd+zzg d8Zd9Zd:Zd;Zy<)=TestSparseUtilscttjdtjttjddtj ttjdt ttjttjddtj y)Nintcint32float32boolid) rsputilsupcastnprfloat64complexfloat complex128selfs e/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/scipy/sparse/tests/test_sputils.py test_upcastzTestSparseUtils.test_upcast sfW^^F+RWW5W^^GY7DW^^FGU;R]]KW^^C-rzz:ctjdgd}ttjdt t ttjd|tj ttd5tjddddttd 5tjdtjdddy#1swYIxYw#1swYyxYw) Nint8dtype)default)az.scipy.sparse does not support dtype object. .*matchOz/scipy.sparse does not support dtype float16. .*) rarrayrrgetdtyperr" assert_raises ValueErrorfloat16)rAs r test_getdtypezTestSparseUtils.test_getdtypes HHaS 'W%%dE:EBW%%da0"'':  B  "   S !  "  C  7   T2:: 6  7 7  " "  7 7sC 1&C, C),C5cttjddttjddttjddttjddttjtjddttjddttjtjdgdttjdggdttjd dttjd dy) N@T@?@16Fr!r!)rr isscalarlikerr*rs rtest_isscalarlikez!TestSparseUtils.test_isscalarlike%sW))#.5W))"-t4W))#.5W))&148W))"((1+6=W))$/6W))"((A3-8%@W))A3%0%8W))$/7W))&159rczttjddttjtjddttjtjdgdt t d5tjddddttjddttjd dttjd dttjd dy#1swYxYw) Nr3Tr6Fz4Inexact indices into sparse matrices are not allowedr'r2r4r5r8r9)rr isintlikerr*r,r-rs rtest_isintlikezTestSparseUtils.test_isintlike2sW&&r*D1W&&rxx{3T:W&&rxx}5u=  H  #   c "  # W&&s+U3W&&v.6W&&t,e4W&&v.6 # #s D11D:cttjddttjddttjddttjddttjdgdfdttjdd dttjd d dttjdd dttjd d dttjdd dttjdgdfd dttjd dd dttjdd dttjdd dttjdd dy)Nr9T)r:)?r:Fr:r:r:r:)r:)nonneg)r:rD)allow_nd)r:r:)rErFr:)r:r:)rrisshapers r test_isshapezTestSparseUtils.test_isshapeAsDW__V,d3W__V,d3W__X.6W__Y/7W__qc1X.6W__WU;DAW__WU;DAW__WT:5AW__WT:5AW__X?GW__qc1X?GW__ZvN W__TF;TBW__Wv>EW__Y@%Hrc ttjddttjddttjdgdttjgddttjtjgddttjtjdgdgdggdttjddy)Nr8Tr!r:r6r!r:r6F)rr issequencerr*rs rtest_issequencezTestSparseUtils.test_issequenceUsW''-t4W'' 2D9W'',d3W'' 2D9W''(;D''15= == >+ 1Bz@ 1$$Ra0 1 1 1' >D''15= == >$4PTU$+MMO H D.''15G GG H9 >D''15= == >$4&I$+MMO A D.  A .. @ AE % % ) ) ) )  1 1 2 2 1 1sGHH(<H52I%I;IH%(H2 5H? I II& containerc tjtjtjj}|d|f}|j }|j jtj|_|jjtj|_td|dzf}|j }|j jtj|_|jjtj|_|j }tj|dzgtj|_tjddgtj|_tjdg|_ |j j|jjftjtjfk(sJ|j j|jjftjtjfk(sJ|j j|jjftjtjfk(sJ|j j|jjftjtjfk(sJ|j j|jjftjtjfk(sJ||||fD]}tj|tj\} } | j| jftjtjfk(sJtj|tj\} } | j| jftjtjfk(sJtj||j j\} } | |j usJ| |jurJtt 5tj|tjdddtj|tj\} } | |j usJ| |jusJy#1swYQxYw)Nr!r#r皙@)rint64iinformaxcopyindicesastypeindptrrr*datar$rsafely_cast_index_arraysr,r-) rrlimaxA32B32A64B64C64r/rsrus r!test_safely_cast_index_compressedz1TestSparseUtils.test_safely_cast_index_compressedsl xx*../D "hhjkk((2 ZZ&&rxx0 D1H &hhjkk((2 ZZ&&rxx0 hhjhhqz: XXq!fBHH5 88SE? !!3::#3#342888LLLL !!3::#3#342888LLLL !!3::#3#342888LLLL !!3::#3#342888LLLL !!3::#3#342888LLLLsC% &A%>>q"((KOGVMM6<<0RXXrxx4HH HH%>>q"((KOGVMM6<<0RXXrxx4HH HH%>>q!))//ROGVaii' ''QXX% %% &: & <  , ,S"(( ; <!::3I#++%%%###  < z=TestSparseUtils.test_safely_cast_index_coo..D2299RXX.D)+c3ZK|]#}|jtj%ywr)rtrrrs rrz=TestSparseUtils.test_safely_cast_index_coo..rrrrn)rrorprrqr rrtuplecoordsr*rvr$rrwr,r-) rrxryrzr{r|r}r/rs rtest_safely_cast_index_cooz*TestSparseUtils.test_safely_cast_index_coosxx*../D "hhjDDD D1H &hhjDDD hhjhhqz*BHHaSM: 88SE?zz!}""bhh...zz!}""bhh...zz!}""bhh...zz!}""bhh...zz!}""bhh...sC% ,A55aBF!9??bhh. ..55aBF!9??bhh. ..55a!9J9JKF!9 + ++ ,: & <  , ,S"(( ; <11#rxx@ayCJJqM))) < xYw)Nr!r:rn)rrorprrqrrroffsetsrtr*rvr$rrwr,r-) rrxryrzr{r|r}r/rs rtest_safely_cast_index_diaz*TestSparseUtils.test_safely_cast_index_diasHxx*../D "hhjkk((2 D1H &hhjkk((2 hhjhhqz* 88SE?{{  BHH,,,{{  BHH,,,{{  BHH,,,{{  BHH,,,{{  BHH,,,sC% (A66q"((CG==BHH, ,,66q"((CG==BHH, ,,66q!))//JGaii' '' (: & <  , ,S"(( ; <223A#++%%% < 2$; D $; R $; r $; $; $ $;  $; 6$; & 6"$; .y9$; i $; & 6"$; & 6"$; & 6"!$;" & 6"#$;$ & 6"%$;& & 6"'$;( & 6")$;* dT+$;,  -$;.  /$;0  1$;2 fv3$;4 $ 5$;6  7$;8  9$;: fv;$;< fv=$;> t?$;@ VfA$;B BC$;D C E$;F "dG$;$JLK$JL [[^ t  F    I)  tfrk! . 4 41 + +rr )__doc__numpyr numpy.testingrrrr, scipy.sparserrrrrr scipy.sparse._sputilsr r rPrrrs)-& *XX(]+]+r