B
    \(                 @   sp   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rPddlmZ nddlmZ dgZdddZdS )zb
The arraycrop module contains functions to crop values from the edges of an
n-dimensional array.
    )divisionabsolute_importprint_functionN)LooseVersionz1.16)_validate_lengths)	_as_pairscropFKc                sn   t j dd trt |}nt| jdd}t fddt|D }|rbt j | |dd}n | }|S )a   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.
    F)copyT)Zas_indexc             3   s*   | ]"\}\}}t | j| | V  qd S )N)sliceshape).0iab)ar 5lib/python3.7/site-packages/skimage/util/arraycrop.py	<genexpr>7   s   zcrop.<locals>.<genexpr>)orderr
   )npZarray	old_numpyr   r   ndimtuple	enumerate)r   Z
crop_widthr
   r   ZcropsZslicesZcroppedr   )r   r   r      s    )Fr	   )__doc__Z
__future__r   r   r   Znumpyr   Zdistutils.versionr   ZVersion__version__r   Znumpy.lib.arraypadr   r   __all__r   r   r   r   r   <module>   s   