
    Pi                     0   d dl Zd dlZd dlmZ d dlmZmZ d Zej	        
                    dddg          d             Zd	 Zej	        
                    dddg          ej	        
                    d
ej        ej        g          d                         ZdS )    N)mutual_reachability_graph)_convert_containerassert_allclosec                  X   t           j                            d          } |                     dd          }|j        |z  }t          j        |d           t          |d          }d}t          j        t          |          5  t          |           ddd           dS # 1 swxY w 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_msgs      /home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/sklearn/cluster/_hdbscan/tests/test_reachibility.py2test_mutual_reachability_graph_error_sparse_formatr      s    
)


"
"C		"bA	aAQ1l++A6G	z	1	1	1 % %!!$$$% % % % % % % % % % % % % % % % % %s   BB#&B#
array_typearray
sparse_csrc                 0   t           j                            d          }|                    dd          }|j        |z  }t          j        |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_graphs       r   &test_mutual_reachability_graph_inplacer      s     )


"
"C		"bA	aAQ1j))A(++Hh<<2a55          c                  ,   t           j                            d          } |                     dd          }|j        |z  }t          |d          }t          |d          }t          |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_sparses         r   7test_mutual_reachability_graph_equivalence_dense_sparser*   &   s    
)


"
"C		!QAcAgG!'<88H.wAFFFN/aHHHONO$;$;$=$=>>>>>r    dtypec                 F   t           j                            d          }|                    dd          }|j        |z                      |          }t          j        |d           t          ||           }|j        |k    sJ t          |          }|j        |k    sJ 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   s        r   .test_mutual_reachability_graph_preserves_dtyper.   3   s     )


"
"C		"bA	
qAQ1j))A7e(++H>U""""""r    )numpyr   r   &sklearn.cluster._hdbscan._reachabilityr   sklearn.utils._testingr   r   r   markparametrizer   r*   float32float64r.    r    r   <module>r7      s
        L L L L L L       
% 
% 
% '>??
! 
! @?
!
? 
? 
? '>??2:rz":;;
# 
# <; @?
# 
# 
#r    