
    Џkhg                        d dl Z d dlZd dlmZ d dlmc mZ d dl	m
Z
 d dlmZ 	 d dlZe j                  j                  edu d      ZdZ e j$                  d       e j$                  de j                  j'                  e      g	      fZd
 Z e j,                  e      d        Ze j,                  d        Ze j                  j3                  dej4                  ej6                  ej8                  ej:                  ej<                  ej>                  ej@                  ejB                  g      d        Z"d Z#d Z$e j                  j3                  dejJ                  ejL                  g      d        Z'e j                  j3                  dejP                  ejR                  g      d        Z*d Z+d Z,d Z- ed      e j                  j3                  dej4                  ej6                  ej8                  ej:                  ej<                  ej\                  g      e j                  j3                  dej^                  ej`                  fejb                  ejd                  fg      d                      Z3y# e$ r dZY Pw xY w)    N)_pep440)assert_equalzpydata/sparse not installedreasonz>pydata/sparse (0.15.1) does not implement necessary operationsCOODOK)marksc                    t          t        j                  j                  d      S t        j                  j	                  t        j                  t         j                        t        j                  |       k  d|  d      S )Nzsparse is not installedr   zsparse version >= z	 required)	sparsepytestmarkskipskipifr   parse__version__Version)min_vers    i/var/www/teggl/fontify/venv/lib/python3.12/site-packages/scipy/sparse/csgraph/tests/test_pydata_sparse.pycheck_sparse_versionr      sh    ~{{'@AA;;f(()GOOG,DD#G9I6       )paramsc                 6    t        t        | j                        S N)getattrr   param)requests    r   
sparse_clsr   #   s    67==))r   c                 f    g dg dg dg dg dg}t        j                  |      } | |      }||fS )N)r      r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )nparray)r   graphA_denseA_sparses       r   graphsr%   (   s>     	E hhuoG'"HHr   funcc                 l    |\  }} | |      } | t        j                  |            }t        ||       y r   sp	csc_arrayr   )r&   r%   r#   r$   actualdesireds         r   test_csgraph_equivr-   6   s4     GX(^F2<<()G!r   c                     | \  }}t         j                  } ||      \  }} |t        j                  |            \  }}||k(  sJ t	        ||       y r   )spgraphconnected_componentsr)   r*   r   )r%   r#   r$   r&   actual_compactual_labelsdesired_compdesired_labelss           r   test_connected_componentsr5   J   sU    GX''D!%hK$(g)>$?!L.,&&&/r   c                     | \  }}t        |      }t        j                  } ||      } |t        j                  |            }t        ||      sJ t        |j                         |j                                y r   )typer/   	laplacianr)   r*   
isinstancer   todenser%   r#   r$   r   r&   r+   r,   s          r   test_laplacianr<   U   sd    GXhJD(^F2<<()Gfj)))!7??#45r   c                 p    | \  }} ||d      } |t        j                  |      d      }t        ||       y Nr   r(   )r%   r&   r#   r$   r+   r,   s         r   test_order_searchr?   b   s9     GX(AF2<<(!,G!r   c                     | \  }}t        |      } ||d      } |t        j                  |      d      }t        ||      sJ t	        |j                         |j                                y r>   )r7   r)   r*   r9   r   r:   )r%   r&   r#   r$   r   r+   r,   s          r   test_tree_searchrA   n   s`     GXhJ(AF2<<(!,Gfj)))!7??#45r   c                     | \  }}t        |      }t        j                  } ||      } |t        j                  |            }t        ||      sJ t        |j                         |j                                y r   )r7   r/   minimum_spanning_treer)   r*   r9   r   r:   r;   s          r   test_minimum_spanning_treerD   }   sd    GXhJ((D(^F2<<()Gfj)))!7??#45r   c                 p   | \  }}t        |      }t        j                  } ||dd      } |t        j                  |      dd      }|j
                  |j
                  k(  sJ t        |j                  |      sJ t        |j                  j                         |j                  j                                y )Nr      )
r7   r/   maximum_flowr)   	csr_array
flow_valuer9   flowr   r:   r;   s          r   test_maximum_flowrK      s    GXhJD(Aq!F2<<(!Q/G 2 2222fkk:...$$&(<(<(>?r   c                 
   | \  }}t         j                  } ||ddddf         }t        j                  |      } ||ddddf         } ||ddddf   j	                               }t        ||       t        ||       y )Nr   rF   r      )r/   "min_weight_full_bipartite_matchingr)   r*   tocoor   )r%   r#   r$   r&   r+   A_cscr,   desired1s           r   'test_min_weight_full_bipartite_matchingrR      s    GX55D(1Q3!8$%FLL!E51ac?#GE!A#qs(O))+,H!"r   z0.15.4zfill_value, comp_funcc                    | \  }}|j                  t              }||_        t        |      } ||      } |t	        j
                  |            }|t        j                  k(  rXt        ||      sJ  ||j                        sJ |j                         }d| ||      <   t        ||j                                y t        ||       y )Ng        )astypefloat
fill_valuer7   r)   r*   r/   rC   r9   r:   r   )	r%   r&   rV   	comp_funcr#   r$   r   r+   r,   s	            r   test_nonzero_fill_valuerX      s    " GXu%H$HhJ(^F2<<()Gw,,,&*---**+++!$'y !VW__./VW%r   )4r   numpyr    scipy.sparser   r)   scipy.sparse.csgraphcsgraphr/   
scipy._libr   numpy.testingr   	Exceptionr   r   
pytestmarkmsgr   xfailsparse_paramsr   fixturer   r%   parametrizeshortest_pathdijkstrafloyd_warshallbellman_fordjohnsonreverse_cuthill_mckeemaximum_bipartite_matchingstructural_rankr-   r5   r<   breadth_first_orderdepth_first_orderr?   breadth_first_treedepth_first_treerA   rD   rK   rR   rC   infisposinfnanisnanrX    r   r   <module>rw      s      & &  & [[$'D   F
 G e$eFKK,=,=S,=,I+JKM }%* &* 
 
 
%%**	""0
6 
W(('*C*CD"" 
W'')A)AB	6	6
6@
# h
%%
 ffbkkRVVRXX./&	
   &S  Fs   I/ /I:9I: