o
    \i                     @   s   d dl Zd dlZd dlmZ d dlmZmZ dd Zej	
dddgd	d
 Zdd Zej	
dddgej	
dejejgdd ZdS )    N)mutual_reachability_graph)_convert_containerassert_allclosec                  C   sx   t jd} | dd}|j| }t |d t|d}d}tjt	|d t
| W d   dS 1 s5w   Y  dS )z=Check that we raise an error if the sparse format is not CSR.r   
           
sparse_cscz&Only sparse CSR matrices are supported)matchN)nprandomRandomStaterandnTfill_diagonalr   pytestraises
ValueErrorr   )rngXerr_msg r   /var/www/www-root/data/www/176.119.141.140/sports-predictor/venv/lib/python3.10/site-packages/sklearn/cluster/_hdbscan/tests/test_reachibility.py2test_mutual_reachability_graph_error_sparse_format   s   


"r   
array_typearray
sparse_csrc                 C   sX   t jd}|dd}|j| }t |d t|| }t|}t|t|ks*J dS )z.Check that the operation is happening inplace.r   r   r   N)	r	   r
   r   r   r   r   r   r   id)r   r   r   mr_graphr   r   r   &test_mutual_reachability_graph_inplace   s   

r   c                  C   sV   t jd} | dd}|j| }t|d}t|dd}t|dd}t||  dS )zGCheck that we get the same results for dense and sparse implementation.r      r      )min_samplesN)	r	   r
   r   r   r   r   r   r   toarray)r   r   X_denseX_sparsemr_graph_densemr_graph_sparser   r   r   7test_mutual_reachability_graph_equivalence_dense_sparse&   s   

r&   dtypec                 C   sf   t jd}|dd}|j| |}t |d t|| }|j|ks&J t	|}|j|ks1J dS )z@Check that the computation preserve dtype thanks to fused types.r   r   r   N)
r	   r
   r   r   r   astyper   r   r'   r   )r   r'   r   r   r   r   r   r   .test_mutual_reachability_graph_preserves_dtype3   s   
r)   )numpyr	   r   &sklearn.cluster._hdbscan._reachabilityr   sklearn.utils._testingr   r   r   markparametrizer   r&   float32float64r)   r   r   r   r   <module>   s    
