o
    Õj”  ć                   @   sÖ   d dl Zd dlZd dlZd dlmZmZ ejg d¢g d¢g d¢ge	dZ
ej ”  e
j”Zdd Zd	d
 Zej dddg”dd Zej dddg”dd Zej dddg”dd Zej dddg”dd ZdS )é    N)Śpixel_graphŚcentral_pixel)é   r   r   )r   r   r   )r   r   r   )Zdtypec                  C   sf   t tdd\} }| jdksJ t| jdksJ tj t | j”dt 	d”g” tj 
|g d¢” d S )Né   ©Śconnectivity)é   r   é   r   ©r   r   é   é   )r   ŚmaskŚshapeŚlenŚdataŚnpŚtestingŚassert_allcloseŚuniqueŚsqrtŚassert_array_equal©ŚgŚn© r   śe/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/skimage/graph/tests/test_pixel_graph.pyŚtest_small_graph   s
    r   c                  C   s¬   t tdd\} }t| tjjsJ t tddd\} }t| tjjs#J t tddd\} }t| tjjs5J tjt	dd t tddd W d    d S 1 sOw   Y  d S )	Nr   r   Śmatrix©r   Śsparse_typeŚarrayz)`sparse_type` must be 'array' or 'matrix')ŚmatchŚunknown)
r   r   Ś
isinstanceŚspŚsparseZ
csr_matrixZ	csr_arrayŚpytestZraisesŚ
ValueErrorr   r   r   r   Śtest_pixel_graph_return_type   s   "’r(   r   r   r    c                 C   s¦   t td| d\}}t||tjd\}}tj |d” t d”}tj ||d d |d |d d |d d g” t||\}}|dksEJ t|\}}|dksQJ d S )Nr   r   )r   ©r   r   é   r   r   )	r   r   r   r   r   r   r   r   r   )r   r   r   ZpxZdsŚs2Ś_r   r   r   Śtest_central_pixel!   s   
2r-   c                 C   s   dd }t ttd|| d\}}t d”}tj |d t td td  ”| ” tj |d t td td  ”d	 ” tj |g d
¢” d S )Nc                 S   s   t  | | ”| S )N©r   Śabs)Z
values_srcZ
values_dstZ	distancesr   r   r   Ś	edge_func4   ó   z%test_edge_function.<locals>.edge_funcr   )r   r   Śedge_functionr   ©r   r   ©r   r   r)   )r   r   r   r
   )	r   Śimager   r   r   r   r   r/   r   )r   r0   r   r   r+   r   r   r   Śtest_edge_function2   s   
ū
((r6   c              	   C   sx   t tt ddg”| d\}}t|jd }|dksJ tj |d dt td td  ” ” tj 	|t 
tj”” d S )Ngö(\Āõč?)Śspacingr   r   é   r3   r4   )r   r5   r   r    r   r   r   Zassert_almost_equalr/   r   ŚarangeŚsize)r   r   r   Z	num_edgesr   r   r   Śtest_default_edge_funcD   s
   (r;   c                 C   s¦   t  g d¢g d¢g d¢g”}dd }t  g d¢g d¢g d¢g d	¢g d
¢g d¢g d¢g d¢g d¢g	”d }t||| d\}}t j |t  |j”” t j | ” |” dS )zOEnsure function `pixel_graph` runs when passing `edge_function` but not `mask`.)r   r   r*   )r   r   é   )r   r	   é	   c                 S   s   t  | | ”d S )Nē      ą?r.   )ŚxŚyŚzr   r   r   ŚfuncR   r1   z)test_no_mask_with_edge_func.<locals>.func)	ē        ē      š?rC   ē      @rC   rC   rC   rC   rC   )	rD   rC   rD   rC   rE   rC   rC   rC   rC   )	rC   rD   rC   rC   rC   rE   rC   rC   rC   )	rE   rC   rC   rC   rD   rC   rE   rC   rC   )	rC   rE   rC   rD   rC   rD   rC   rE   rC   )	rC   rC   rE   rC   rD   rC   rC   rC   rE   )	rC   rC   rC   rE   rC   rC   rC   rD   rC   )	rC   rC   rC   rC   rE   rC   rD   rC   rD   )	rC   rC   rC   rC   rC   rE   rC   rD   rC   r>   )r2   r   N)r   r    r   r   r   r9   r:   Ztoarray)r   r5   rB   Z
expected_gr   r   r   r   r   Śtest_no_mask_with_edge_funcM   s(   ÷’ó’rF   )Śnumpyr   Zscipyr$   r&   Zskimage.graph._graphr   r   r    Śboolr   ŚrandomZdefault_rngr   r5   r   r(   ŚmarkZparametrizer-   r6   r;   rF   r   r   r   r   Ś<module>   s      


