o
    i                     @   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 operationsZCOOZDOK)Z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)Zmin_ver r   g/home/kim/smarthome/.venv/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   )spgraphZconnected_componentsr    r!   r   )r   r   r   r   Zactual_compZactual_labelsZdesired_compZdesired_labelsr   r   r   test_connected_componentsJ   s   r&   c                 C   P   | \}}t |}tj}||}|t|}t||sJ t| |  d S r   )typer%   Z	laplacianr    r!   
isinstancer   todenser   r   r   r   r   r"   r#   r   r   r   test_laplacianU      r,   c                 C   s0   | \}}||d}|t |d}t|| d S Nr   r   )r   r   r   r   r"   r#   r   r   r   test_order_searchb   s   
r/   c                 C   sN   | \}}t |}||d}|t|d}t||sJ t| |  d S r.   )r(   r    r!   r)   r   r*   )r   r   r   r   r   r"   r#   r   r   r   test_tree_searchn   s   
r0   c                 C   r'   r   )r(   r%   minimum_spanning_treer    r!   r)   r   r*   r+   r   r   r   test_minimum_spanning_tree}   r-   r2   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      )
r(   r%   Zmaximum_flowr    Z	csr_arrayZ
flow_valuer)   Zflowr   r*   r+   r   r   r   test_maximum_flow   s   r4   c                 C   sR   | \}}t j}||ddddf }|t|ddddf }t|| d S )Nr   r3   r      )r%   Z"min_weight_full_bipartite_matchingr    r!   r   )r   r   r   r   r"   r#   r   r   r   'test_min_weight_full_bipartite_matching   s
   r6   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        )Zastypefloat
fill_valuer(   r    r!   r%   r1   r)   r*   r   )	r   r   r8   Z	comp_funcr   r   r   r"   r#   r   r   r   test_nonzero_fill_value   s   

r9   )4r   numpyr   Zscipy.sparser   r    Zscipy.sparse.csgraphZcsgraphr%   Z
scipy._libr   Znumpy.testingr   	Exceptionr   r
   Z
pytestmarkmsgr   ZxfailZsparse_paramsr   Zfixturer   r   ZparametrizeZshortest_pathZdijkstraZfloyd_warshallZbellman_fordZjohnsonZreverse_cuthill_mckeeZmaximum_bipartite_matchingZstructural_rankr$   r&   r,   Zbreadth_first_orderZdepth_first_orderr/   Zbreadth_first_treeZdepth_first_treer0   r2   r4   r6   r1   infZisposinfnanisnanr9   r   r   r   r   <module>   s    
	



	

