a
    
d$                     @   s  d dl Z d dlZd dlZd dlmZ d dlmZ d dlm	Z	 dd Z
dd Zd	d
 Zdd Zejdg dejdejejgdd Zdd Zejdejejej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dd Z dd Z!dd Z"dS )     N)assert_array_almost_equal)_supported_float_type)reconstructionc                   C   s    t ttdtdd dS )z0Test reconstruction with image and mask of zeros)      r   N)r   r   npzeros r	   r	   u/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/skimage/morphology/tests/test_reconstruction.py
test_zeros
   s    r   c                   C   s    t ttdtdd dS )z9Test reconstruction where the image and mask are the same)r   r      N)r   r   r   onesr	   r	   r	   r
   test_image_equals_mask   s    r   c                  C   s,   t d} t dd }tt| |d dS )zATest reconstruction where the image is uniform and less than maskr   r      r   Nr   r   r   r   imagemaskr	   r	   r
   test_image_less_than_mask   s    
r   c                  C   s4   t d} d| d< t dd }tt| |d dS )z'Test reconstruction with one peak pixelr   r   )r   r      Nr   r   r	   r	   r
   test_one_image_peak   s    
r   minsize)N   i N  i@  i8 dtypec                 C   s&  t jg dg dg dg dg dg dg|d}t jg dg dg dg dg dg dg|d}t jg dg dg dg dg dg dg|d}| d	urtt| |j }t| |j|  }t |||f}t |||f}t |||f}t||}|jt	|jksJ t
|| d	S )
z=Test reconstruction with two peak pixels isolated by the mask)	r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   r   )	   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   N)r   arraymathceilsqrtsizeZtiler   r   r   r   )r   r   r   r   expectedZnrowZncoloutr	   r	   r
   test_two_image_peaks'   sH    



r$   c                  C   s$   t tdtd} t| d dS )zDTest reconstruction with an image of all zeros and a mask that's not)
   r%   r   N)r   r   r   r   r   )resultr	   r	   r
   test_zero_image_one_maskK   s    r'   c                 C   sf   t jg d| d}t jg d| d}t||dd}|jt|jksFJ t jg d| d}t|| dS )z@Test reconstruction by erosion, which should fill holes in mask.
r      r)   r)   r)   r)   r)   r)   r)   r   r   
r   r      r   r   r   r   r   r   r   erosionmethod)
r   r   r+   r   r   r   r   r   r   r   N)r   r   r   r   r   r   )r   seedr   r&   r"   r	   r	   r
   test_fill_holeQ   s    r0   c                  C   s   t d} t d}tt" t| d |dd W d    n1 sF0    Y  tt" t| d |dd W d    n1 s0    Y  d S )Nr   r   dilationr-   g      ?r,   r   r   pytestraises
ValueErrorr   r/   r   r	   r	   r
   test_invalid_seed^   s    


$
r7   c                  C   s   t d} t d}tt$ t| |t dd W d    n1 sH0    Y  tt$ t| |t dd W d    n1 s0    Y  t| |t dd d S )Nr   )r   r   )	footprint)r   r   r   r   r2   r6   r	   r	   r
   test_invalid_footprinti   s    

$$r:   c                  C   sX   t g d} t g d}tt t| |dd W d    n1 sJ0    Y  d S )Nr(   r*   Zfoor-   )r   r   r3   r4   r5   r   r6   r	   r	   r
   test_invalid_methodu   s    r;   c               
   C   s   t g dg dg dg dg dg dg} t g dg dg dg dg dg dg}tt2 t| |dt dt dd	gd
 W d   n1 s0    Y  dS )z:Test reconstruction with invalid not None offset parameter)r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r1   r9   r   r   r.   r8   offsetN)r   r   r3   r4   r5   r   r   r   r	   r	   r
   test_invalid_offset_not_none|   s$    

r>   c               	   C   sT   t g d} t g d}t g d}tt| |dt dt dgd| dS )	z/Test reconstruction with valid offset parameterr*   )
r   r)   r+   r)   r)   r)   r)   r   r   r   )
r   r   r+   r+   r+   r+   r+   r   r   r   r1   r   r   r<   N)r   r   r   r   r   )r/   r   r"   r	   r	   r
   test_offset_not_none   s    r?   )#r   numpyr   r3   Znumpy.testingr   Zskimage._shared.utilsr   Z"skimage.morphology.grayreconstructr   r   r   r   r   markZparametrizeZuint8float32r$   r'   Zint8int16Zuint16int32Zuint32int64Zuint64float16float64r0   r7   r:   r;   r>   r?   r	   r	   r	   r
   <module>   s.   
"

