ó
 \c           @   s    d  Z  d d l Z d d l m Z d d l m Z d d l m Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d S(   s!  
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
iĸĸĸĸN(   t   reconstruction(   t   testing(   t   assert_array_almost_equalc           C   s,   t  t t j d  t j d   d  d S(   s0   Test reconstruction with image and mask of zerosi   i   i    N(   i   i   (   i   i   (   R   R    t   npt   zeros(    (    (    sK   lib/python2.7/site-packages/skimage/morphology/tests/test_reconstruction.pyt
   test_zeros   s    c           C   s,   t  t t j d  t j d   d  d S(   s9   Test reconstruction where the image and mask are the samei   i   i   N(   i   i   (   i   i   (   R   R    R   t   ones(    (    (    sK   lib/python2.7/site-packages/skimage/morphology/tests/test_reconstruction.pyt   test_image_equals_mask   s    c          C   s<   t  j d  }  t  j d  d } t t |  |  d  d S(   sA   Test reconstruction where the image is uniform and less than maski   i   i   N(   i   i   (   i   i   (   R   R   R   R    (   t   imaget   mask(    (    sK   lib/python2.7/site-packages/skimage/morphology/tests/test_reconstruction.pyt   test_image_less_than_mask   s    c          C   sF   t  j d  }  d |  d <t  j d  d } t t |  |  d  d S(   s'   Test reconstruction with one peak pixeli   i   i   N(   i   i   (   i   i   (   i   i   (   R   R   R   R    (   R   R	   (    (    sK   lib/python2.7/site-packages/skimage/morphology/tests/test_reconstruction.pyt   test_one_image_peak$   s    
c          C   s-  t  j d d d d d d d d g d d d d d d d d g d d d d d d d d g d d d d d d d d g d d d d d d d d g d d d d d d d d g g  }  t  j d d d d d d d d g d d d d d d d d g d d d d d d d d g d d d d d d d d g d d d d d d d d g d d d d d d d d g g  } t  j d d d d d d d d g d d d d d d d d g d d d d d d d d g d d d d d d d d g d d d d d d d d g d d d d d d d d g g  } t t |  |  |  d S(   s=   Test reconstruction with two peak pixels isolated by the maski   i   i   i   N(   R   t   arrayR   R    (   R   R	   t   expected(    (    sK   lib/python2.7/site-packages/skimage/morphology/tests/test_reconstruction.pyt   test_two_image_peaks,   s&    !$!$!$c          C   s2   t  t j d  t j d   }  t |  d  d S(   sD   Test reconstruction with an image of all zeros and a mask that's noti
   i    N(   i
   i
   (   i
   i
   (   R    R   R   R   R   (   t   result(    (    sK   lib/python2.7/site-packages/skimage/morphology/tests/test_reconstruction.pyt   test_zero_image_one_maskE   s    !c          C   s§   t  j d d d d d d d d d d g
  }  t  j d d d d d d d d d d g
  } t |  | d d	 } t | t  j d d d d d d d d d d g
   d
 S(   s@   Test reconstruction by erosion, which should fill holes in mask.i    i   i   i   i   i   i   t   methodt   erosionN(   R   R   R    R   (   t   seedR	   R   (    (    sK   lib/python2.7/site-packages/skimage/morphology/tests/test_reconstruction.pyt   test_fill_holeK   s    --c       
   C   s|   t  j d  }  t  j d  } t j t   t |  d | d d Wd  QXt j t   t |  d | d d Wd  QXd  S(	   Ni   i   R   t   dilationg      ā?R   (   i   i   (   i   i   (   R   R   R   t   raisest
   ValueErrorR    (   R   R	   (    (    sK   lib/python2.7/site-packages/skimage/morphology/tests/test_reconstruction.pyt   test_invalid_seedS   s    c          C   sĒ   t  j d  }  t  j d  } t j t  ! t |  | d t  j d  Wd  QXt j t  ! t |  | d t  j d  Wd  QXt |  | d t  j d	  d  S(
   Ni   t   selemi   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   R   R   R   R   R   R    (   R   R	   (    (    sK   lib/python2.7/site-packages/skimage/morphology/tests/test_reconstruction.pyt   test_invalid_selem^   s    c          C   s   t  j d d d d d d d d d d g
  }  t  j d d d d d d d d d d g
  } t j t   t |  | d d	 Wd  QXd  S(
   Ni    i   i   i   i   i   i   R   t   foo(   R   R   R   R   R   R    (   R   R	   (    (    sK   lib/python2.7/site-packages/skimage/morphology/tests/test_reconstruction.pyt   test_invalid_methodj   s    --(   t   __doc__t   numpyR   t"   skimage.morphology.greyreconstructR    t   skimage._sharedR   t   skimage._shared.testingR   R   R   R
   R   R   R   R   R   R   R   (    (    (    sK   lib/python2.7/site-packages/skimage/morphology/tests/test_reconstruction.pyt   <module>	   s   									