U
    ?h	                     @   s,   d Z ddlZ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.
    N)IntegralcropFKc                    s  t j dd t|tr*||gg j }nt|d trt|dkr^|d |d gg j }qt|dkrx|g j }qtdt| dnFt|dkr|d g j }n(t| jkr|}ntdt| dt fdd	t|D }|r
t j | |d
d}n | }|S )a3  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),) or (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)copyr         z"crop_width has an invalid length: zO
crop_width should be a sequence of N pairs, a single pair, or a single integerc                 3   s*   | ]"\}\}}t | j| | V  qd S )N)sliceshape).0iabar H/var/www/html/venv/lib/python3.8/site-packages/skimage/util/arraycrop.py	<genexpr>C   s   
zcrop.<locals>.<genexpr>T)orderr   )	nparray
isinstancer   ndimlen
ValueErrortuple	enumerate)r   Z
crop_widthr   r   ZcropsZslicesZcroppedr   r   r   r      s2    
)Fr   )__doc__numpyr   numbersr   __all__r   r   r   r   r   <module>   s   