o
    	h                     @   s  d dl Z d dlZd dlmZ d dlm  mZ d dl	m
Z
 d dlmZ zd dlZW n ey4   dZY nw e jjedu ddZdZe de jde jjedgd	fZd
d Ze jeddd Ze jdd Ze jdejejejejejejej ej!gdd Z"dd Z#dd Z$e jdej%ej&gdd Z'e jdej(ej)gdd Z*dd Z+dd Z,d 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j0fej1ej2fgd$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                 C   s@   t d u rtjjddS tjjtt jt| k d|  ddS )Nzsparse is not installedr   zsparse version >= z	 required)	sparsepytestmarkskipskipifr   parse__version__Version)min_ver r   a/var/www/vscode/kcb/lib/python3.10/site-packages/scipy/sparse/csgraph/tests/test_pydata_sparse.pycheck_sparse_version   s   
r   )paramsc                 C   s   t t| jS N)getattrr	   param)requestr   r   r   
sparse_cls#   s   r   c                 C   s<   g dg dg dg dg dg}t |}| |}||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_sparser   r   r   graphs(   s   
r!   funcc                 C   s,   |\}}| |}| t |}t|| d S r   sp	csc_arrayr   )r"   r!   r   r    actualdesiredr   r   r   test_csgraph_equiv6   s   r(   c                 C   sF   | \}}t j}||\}}|t|\}}||ksJ t|| d S r   )spgraphconnected_componentsr$   r%   r   )r!   r   r    r"   actual_compactual_labelsdesired_compdesired_labelsr   r   r   test_connected_componentsJ   s   r/   c                 C   P   | \}}t |}tj}||}|t|}t||sJ t| |  d S r   )typer)   	laplacianr$   r%   
isinstancer   todenser!   r   r    r   r"   r&   r'   r   r   r   test_laplacianU      r6   c                 C   s0   | \}}||d}|t |d}t|| d S Nr   r#   )r!   r"   r   r    r&   r'   r   r   r   test_order_searchb   s   
r9   c                 C   sN   | \}}t |}||d}|t|d}t||sJ t| |  d S r8   )r1   r$   r%   r3   r   r4   )r!   r"   r   r    r   r&   r'   r   r   r   test_tree_searchn   s   
r:   c                 C   r0   r   )r1   r)   minimum_spanning_treer$   r%   r3   r   r4   r5   r   r   r   test_minimum_spanning_tree}   r7   r<   c                 C   sn   | \}}t |}tj}||dd}|t|dd}|j|jks"J t|j|s*J t|j	 |j	  d S )Nr      )
r1   r)   maximum_flowr$   	csr_array
flow_valuer3   flowr   r4   r5   r   r   r   test_maximum_flow   s   rB   c                 C   sR   | \}}t j}||ddddf }|t|ddddf }t|| d S )Nr   r=   r      )r)   "min_weight_full_bipartite_matchingr$   r%   r   )r!   r   r    r"   r&   r'   r   r   r   'test_min_weight_full_bipartite_matching   s
   rE   z0.15.4zfill_value, comp_funcc           	      C   s   | \}}| t}||_t|}||}|t|}|tjkrAt||s'J ||js.J |	 }d|||< t
||	  d S t
|| d S )Ng        )astypefloat
fill_valuer1   r$   r%   r)   r;   r3   r4   r   )	r!   r"   rH   	comp_funcr   r    r   r&   r'   r   r   r   test_nonzero_fill_value   s   

rJ   )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(   r/   r6   breadth_first_orderdepth_first_orderr9   breadth_first_treedepth_first_treer:   r<   rB   rE   r;   infisposinfnanisnanrJ   r   r   r   r   <module>   s    
	



	

