
    Uig                     2   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n# e$ r dZY nw xY we j                            edu d          ZdZ e j        d           e j        de j                            e          g	          fZd
 Z e j        e          d             Ze j        d             Ze j                            dej        ej        ej        ej        ej        ej        ej         ej!        g          d             Z"d Z#d Z$e j                            dej%        ej&        g          d             Z'e j                            dej(        ej)        g          d             Z*d Z+d Z,d Z- ed          e j                            dej        ej        ej        ej        ej        ej.        g          e j                            dej/        ej0        fej1        ej2        fg          d                                     Z3dS )    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                            d          S t          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    /var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/scipy/sparse/csgraph/tests/test_pydata_sparse.pycheck_sparse_versionr      sm    ~{'@AAA;f())GOG,D,DD6G666        )paramsc                 6    t          t          | j                  S N)getattrr   param)requests    r   
sparse_clsr   #   s    67=)))r   c                 j    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%   (   sW     	E huooGz'""HHr   funcc                     |\  }} | |          } | t          j        |                    }t          ||           d S r   sp	csc_arrayr   )r&   r%   r#   r$   actualdesireds         r   test_csgraph_equivr-   6   sJ     GXT(^^Fd2<(())G!!!!!r   c                     | \  }}t           j        } ||          \  }} |t          j        |                    \  }}||k    sJ t	          ||           d S r   )spgraphconnected_componentsr)   r*   r   )r%   r#   r$   r&   actual_compactual_labelsdesired_compdesired_labelss           r   test_connected_componentsr5   J   sk    GX'D!%hK$(Dg)>)>$?$?!L.,&&&&/////r   c                 "   | \  }}t          |          }t          j        } ||          } |t          j        |                    }t          ||          sJ t          |                                |                                           d S r   )typer/   	laplacianr)   r*   
isinstancer   todenser%   r#   r$   r   r&   r+   r,   s          r   test_laplacianr<   U   s    GXhJDT(^^Fd2<(())Gfj)))))!!7??#4#455555r   c                     | \  }} ||d          } |t          j        |          d          }t          ||           d S Nr   r(   )r%   r&   r#   r$   r+   r,   s         r   test_order_searchr?   b   sP     GXT(AFd2<((!,,G!!!!!r   c                    | \  }}t          |          } ||d          } |t          j        |          d          }t          ||          sJ t	          |                                |                                           d S r>   )r7   r)   r*   r9   r   r:   )r%   r&   r#   r$   r   r+   r,   s          r   test_tree_searchrA   n   s     GXhJT(AFd2<((!,,Gfj)))))!!7??#4#455555r   c                 "   | \  }}t          |          }t          j        } ||          } |t          j        |                    }t          ||          sJ t          |                                |                                           d S r   )r7   r/   minimum_spanning_treer)   r*   r9   r   r:   r;   s          r   test_minimum_spanning_treerD   }   s    GXhJ(DT(^^Fd2<(())Gfj)))))!!7??#4#455555r   c                 l   | \  }}t          |          }t          j        } ||dd          } |t          j        |          dd          }|j        |j        k    sJ t          |j        |          sJ t          |j        	                                |j        	                                           d S )Nr      )
r7   r/   maximum_flowr)   	csr_array
flow_valuer9   flowr   r:   r;   s          r   test_maximum_flowrK      s    GXhJDT(Aq!!Fd2<((!Q//G 22222fk:.....$$&&(<(<(>(>?????r   c                 >   | \  }}t           j        } ||ddddf                   }t          j        |          } ||ddddf                   } ||ddddf                                                   }t          ||           t          ||           d S )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5DT(1Q3!8$%%FL!!Ed51ac?##GtE!A#qs(O))++,,H!!!"""""r   z0.15.4zfill_value, comp_funcc                    | \  }}|                     t                    }||_        t          |          } ||          } |t	          j        |                    }|t          j        k    rjt          ||          sJ  ||j                  sJ |	                                }d| ||          <   t          ||	                                           d S t          ||           d S )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T(^^Fd2<(())Gw,,,&*-----y*+++++!!$'yy  !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      sX              & & & & & & & & &       & & & & & &MMMM   FFF [$'D   F F
 G e$$eFK,=,=S,=,I,I+JKKKM   }%%%* * &%* 
 
 
 
%*	 " " "0 0 0
6 
6 
6 
W('*CD " " " 
W')AB 	6 	6 	6
6 
6 
6@ @ @
# 
# 
# h
%
 
 fbkRVRX./ & &	 
 
   & & &s   * 44