
\c           @` s   d  Z  d d l m Z m Z m Z d d l Z d d l m Z	 e	 e j
  e	 d  k  Z e rr d d l m Z n d d l m Z d g Z e d	 d
  Z d S(   sb   
The arraycrop module contains functions to crop values from the edges of an
n-dimensional array.
i    (   t   divisiont   absolute_importt   print_functionN(   t   LooseVersions   1.16(   t   _validate_lengths(   t	   _as_pairst   cropt   Kc         ` s   t  j   d t   t r- t   |  } n t |   j d t } t   f d   t	 |  D  } | r t  j   | d | d t } n
   | } | S(   s   Crop array `ar` by `crop_width` along each dimension.

    Parameters
    ----------
    ar : array-like of rank N
        Input array.
    crop_width : {sequence, int}
        Number of values to remove from the edges of each axis.
        ``((before_1, after_1),`` ... ``(before_N, after_N))`` specifies
        unique crop widths at the start and end of each axis.
        ``((before, after),)`` specifies a fixed start and end crop
        for every axis.
        ``(n,)`` or ``n`` for integer ``n`` is a shortcut for
        before = after = ``n`` for all axes.
    copy : bool, optional
        If `True`, ensure the returned array is a contiguous copy. Normally,
        a crop operation will return a discontiguous view of the underlying
        input array.
    order : {'C', 'F', 'A', 'K'}, optional
        If ``copy==True``, control the memory layout of the copy. See
        ``np.copy``.

    Returns
    -------
    cropped : array
        The cropped array. If ``copy=False`` (default), this is a sliced
        view of the input array.
    t   copyt   as_indexc         3` s5   |  ]+ \ } \ } } t  |   j | |  Vq d  S(   N(   t   slicet   shape(   t   .0t   it   at   b(   t   ar(    s5   lib/python2.7/site-packages/skimage/util/arraycrop.pys	   <genexpr>7   s   t   order(
   t   npt   arrayt   Falset	   old_numpyR   R   t   ndimt   Truet   tuplet	   enumerate(   R   t
   crop_widthR   R   t   cropst   slicest   cropped(    (   R   s5   lib/python2.7/site-packages/skimage/util/arraycrop.pyR      s    "
(   t   __doc__t
   __future__R    R   R   t   numpyR   t   distutils.versionR   t   Versiont   __version__R   t   numpy.lib.arraypadR   R   t   __all__R   R   (    (    (    s5   lib/python2.7/site-packages/skimage/util/arraycrop.pyt   <module>   s   	