o
    :ήc                     @   s   d 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dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! ZdS )"a!  
These tests are originally part of CellProfiler, code licensed under both GPL and BSD licenses.

Website: http://www.cellprofiler.org
Copyright (c) 2003-2009 Massachusetts Institute of Technology
Copyright (c) 2009-2011 Broad Institute
All rights reserved.
Original author: Lee Kamentsky
    N)assert_array_almost_equal)expected_warningsreconstructionc                   C       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   S/tmp/pip-target-vg8gfxp4/lib/python/skimage/morphology/tests/test_reconstruction.py
test_zeros      r   c                   C   r   )z9Test reconstruction where the image and mask are the same)r   r      N)r   r   r	   onesr   r   r   r   test_image_equals_mask   r   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   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 g dg dg dg dg dg dg}t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   N)r	   arrayr   r   )r   r   expectedr   r   r   test_two_image_peaks-   s,   


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_maskF   s   r&   c                  C   sB   t g d} t g d}t| |dd}t|t g d 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   erosionmethod)
r   r   r*   r   r   r   r   r   r   r   N)r	   r!   r   r   )seedr   r%   r   r   r   test_fill_holeL   s   r/   c                  C   s   t d} t d}tt t| d |dd W d    n1 s#w   Y  tt t| d |dd W d    d S 1 sBw   Y  d S )Nr   r   dilationr,   g      ?r+   r	   r   pytestraises
ValueErrorr   r.   r   r   r   r   test_invalid_seedT   s   



"r6   c                  C   s   t d} t d}tt t| |t dd W d    n1 s$w   Y  tt t| |t dd W d    n1 sCw   Y  t| |t dd d S )Nr   )r   r   )	footprint)r   r   r   r   r1   r5   r   r   r   test_invalid_footprint_   s   

r9   c                  C   sZ   t g d} t g d}tt t| |dd W d    d S 1 s&w   Y  d S )Nr'   r)   foor,   )r	   r!   r2   r3   r4   r   r5   r   r   r   test_invalid_methodk   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 t| |dt dt dd	gd
 W d   dS 1 sPw   Y  dS )z:Test reconstruction with invalid not None offset parameterr   r   r   r   r    r0   r8   r   r   r-   r7   offsetN)r	   r!   r2   r3   r4   r   r   r   r   r   r   test_invalid_offset_not_noner   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   r0   r   r   r<   N)r	   r!   r   r   r   )r.   r   r"   r   r   r   test_offset_not_none   s   r@   c                  C   sD   d} t | d g ddlm} W d    d S 1 sw   Y  d S )Nz@Importing from skimage.morphology.greyreconstruct is deprecated.z|\A\Zr   r   )r   "skimage.morphology.greyreconstructr   )msgr   r   r   r   test_deprecated_import   s   "rC   c                  C   sb   t g d} t g d}tdg t| |dt dd W d    d S 1 s*w   Y  d S )Nr)   r?   z%`selem` is a deprecated argument namer0   r   )r-   selem)r	   r!   r   r   r   r5   r   r   r   test_selem_kwarg_deprecation   s
   "rE   )__doc__numpyr	   r2   numpy.testingr   skimage._shared._warningsr   "skimage.morphology.grayreconstructr   r   r   r   r   r#   r&   r/   r6   r9   r;   r>   r@   rC   rE   r   r   r   r   <module>   s(    	