U
    ?hÈ  ã                   @   st   d dl Zd dlmZmZ ejdd d gd ddgd dd ggedZej 	¡  ej
¡Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )é    N)Úpixel_graphÚcentral_pixelé   )Zdtypec                  C   sj   t tdd\} }| jdkst‚t| jƒdks0t‚tj t 	| j¡dt 
d¡g¡ tj |dddd	g¡ d S )
Né   ©Úconnectivity)é   r   é   r   r   r   é   é   )r   ÚmaskÚshapeÚAssertionErrorÚlenÚdataÚnpÚtestingÚassert_allcloseÚuniqueÚsqrtÚassert_array_equal)ÚgÚn© r   úV/var/www/html/venv/lib/python3.8/site-packages/skimage/graph/tests/test_pixel_graph.pyÚtest_small_graph   s
     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sˆt	‚t| ƒ\}}|dks t	‚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 |d
dddg¡ d S )Nc                 S   s   t  | | ¡| S )N)r   Úabs)Z
values_srcZ
values_dstZ	distancesr   r   r   Ú	edge_func!   s    z%test_edge_function.<locals>.edge_funcr   )r   r   Zedge_function©r   r   ©r   r   r   )r   r   r   r   r   r
   r   )	r   Úimager   r   r   r   r   r!   r   )r"   r   r   r   r   r   r   Útest_edge_function    s       ÿ

((r&   c               	   C   sv   t tt ddg¡d\} }t| jƒd }|dks4t‚tj | d dt 	td td  ¡ ¡ tj 
|t tj¡¡ d S )Ngö(\Âõè?)Úspacingr   é   r#   r$   )r   r%   r   Úarrayr   r   r   r   Zassert_almost_equalr!   r   ZarangeÚsize)r   r   Z	num_edgesr   r   r   Útest_default_edge_func-   s     ÿr+   )Únumpyr   Zskimage.graph._graphr   r   r)   Úboolr   ÚrandomZdefault_rngr   r%   r   r    r&   r+   r   r   r   r   Ú<module>   s   &