403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.19.244.133
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib64/python3.7/site-packages/numpy/lib/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib64/python3.7/site-packages/numpy/lib/__pycache__/arraypad.cpython-37.pyc
B

��FdD��@sdZddlmZmZmZddlZdgZd3dd�Zdd	�Z	d4dd�Z
d5d
d�Zd6dd�Zd7dd�Z
d8dd�Zd9dd�Zd:dd�Zd;dd�Zd<dd�Zd=dd�Zd>dd �Zd?d!d"�Zd@d#d$�ZdAd%d&�ZdBd'd(�ZdCd)d*�ZdDd+d,�ZdEd.d/�Zd0d1�Zd2d�ZdS)Fzl
The arraypad module contains a group of functions to pad values onto the edges
of an n-dimensional array.

�)�division�absolute_import�print_functionN�padFcs�t��fdd�t|j�D��}|s8t�d��d�}nt���dd�}|�|�}x0t��D]$\}}|j||kr^|j||d�}q^W|S)a�
    Create an ndarray of `shape` with increments along specified `axis`

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    shape : tuple of ints
        Shape of desired array. Should be equivalent to `arr.shape` except
        `shape[axis]` which may have any positive value.
    axis : int
        Axis to increment along.
    reverse : bool
        If False, increment in a positive fashion from 1 to `shape[axis]`,
        inclusive. If True, the bounds are the same but the order reversed.

    Returns
    -------
    padarr : ndarray
        Output array sized to pad `arr` along `axis`, with linear range from
        1 to `shape[axis]` along specified `axis`.

    Notes
    -----
    The range is deliberately 1-indexed for this specific use case. Think of
    this algorithm as broadcasting `np.arange` to a single `axis` of an
    arbitrarily shaped ndarray.

    c3s&|]\}}|�krdn��VqdS)�N�)�.0�i�x)�axis�shaper�E/opt/alt/python37/lib64/python3.7/site-packages/numpy/lib/arraypad.py�	<genexpr>0sz"_arange_ndarray.<locals>.<genexpr>rr���)r)�tuple�	enumerater�npZarange�reshape�repeat)�arrrr�reverseZ	initshapeZpadarrr	Zdimr)rrr
�_arange_ndarrays
rcCst�|tj�r|j|d�dS)z�
    Rounds arr inplace if destination dtype is integer.

    Parameters
    ----------
    arr : ndarray
        Input array.
    dtype : dtype
        The dtype of the destination array.

    )�outN)rZ
issubdtype�integer�round)r�dtyperrr
�_round_ifneeded=srrcsx�dkr|St��fdd�t|j�D��}|dkrPtjtj||jd�|f�d�Stjt�|�|�|j�|f�d�SdS)a
    Prepend constant `val` along `axis` of `arr`.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : int
        Amount of padding to prepend.
    val : scalar
        Constant value to use. For best results should be of type `arr.dtype`;
        if not `arr.dtype` will be cast to `arr.dtype`.
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, with `pad_amt` constant `val` prepended along `axis`.

    rc3s"|]\}}|�kr|n�VqdS)Nr)rr	r
)r�pad_amtrr
resz!_prepend_const.<locals>.<genexpr>)r)rN)rrrr�concatenate�zerosr�astype)rr�valr�padshaper)rrr
�_prepend_constMsr#csx�dkr|St��fdd�t|j�D��}|dkrPtj|tj||jd�f�d�Stj|t�|�|�|j�f�d�SdS)a
    Append constant `val` along `axis` of `arr`.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : int
        Amount of padding to append.
    val : scalar
        Constant value to use. For best results should be of type `arr.dtype`;
        if not `arr.dtype` will be cast to `arr.dtype`.
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, with `pad_amt` constant `val` appended along `axis`.

    rc3s"|]\}}|�kr|n�VqdS)Nr)rr	r
)rrrr
r�sz _append_const.<locals>.<genexpr>)r)rN)rrrrrrrr )rrr!rr"r)rrr
�
_append_constosr$csn|dkr|St�fdd�t|j�D��}t�fdd�t|j�D��}||�|�}tj|j|�d�|f�d�S)a�
    Prepend `pad_amt` to `arr` along `axis` by extending edge values.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : int
        Amount of padding to prepend.
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, extended by `pad_amt` edge values appended along `axis`.

    rc3s&|]\}}|�krtd�ndVqdS)Nr)�slice)rr	r
)rrr
r�sz _prepend_edge.<locals>.<genexpr>c3s"|]\}}|�kr|ndVqdS)rNr)rr	r
)rrr
r�s)r)rrrrrrr)rrr�
edge_slice�
pad_singleton�edge_arrr)rr
�
_prepend_edge�sr)csp|dkr�St��fdd�t�j�D��}t�fdd�t�j�D��}�|�|�}tj�|j|�d�f�d�S)a�
    Append `pad_amt` to `arr` along `axis` by extending edge values.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : int
        Amount of padding to append.
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, extended by `pad_amt` edge values prepended along
        `axis`.

    rc3s0|](\}}|�krtd�n�j�dVqdS)Nr)r%r)rr	r
)rrrr
r�sz_append_edge.<locals>.<genexpr>c3s"|]\}}|�kr|ndVqdS)rNr)rr	r
)rrr
r�s)r)rrrrrrr)rrrr&r'r(r)rrr
�_append_edge�sr*c
s��dkr|St��fdd�t|j�D��}t||�dd��tj�}t�fdd�t|j�D��}t�fdd�t|j�D��}||�|�����}||t	��}	||	}||7}t
||j�tj|�|j�|f�d�S)	aF
    Prepend linear ramp along `axis`.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : int
        Amount of padding to prepend.
    end : scalar
        Constal value to use. For best results should be of type `arr.dtype`;
        if not `arr.dtype` will be cast to `arr.dtype`.
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, with `pad_amt` values prepended along `axis`. The
        prepended region ramps linearly from the edge value to `end`.

    rc3s"|]\}}|�kr|n�VqdS)Nr)rr	r
)rrrr
r�sz _prepend_ramp.<locals>.<genexpr>T)rc3s&|]\}}|�krtd�ndVqdS)Nr)r%)rr	r
)rrr
r�sc3s"|]\}}|�kr|ndVqdS)rNr)rr	r
)rrr
r�s)r)
rrrrr r�float64rr�floatrrr)
rr�endrr"�ramp_arrr&r'�edge_pad�sloper)rrr
�
_prepend_ramp�s r1c
s��dkr|St��fdd�t|j�D��}t||�dd��tj�}t�fdd�t|j�D��}t�fdd�t|j�D��}||�|�����}||t	��}	||	}||7}t
||j�tj||�|j�f�d�S)	aB
    Append linear ramp along `axis`.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : int
        Amount of padding to append.
    end : scalar
        Constal value to use. For best results should be of type `arr.dtype`;
        if not `arr.dtype` will be cast to `arr.dtype`.
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, with `pad_amt` values appended along `axis`. The
        appended region ramps linearly from the edge value to `end`.

    rc3s"|]\}}|�kr|n�VqdS)Nr)rr	r
)rrrr
r&sz_append_ramp.<locals>.<genexpr>F)rc3s&|]\}}|�krtd�ndVqdS)Nr)r%)rr	r
)rrr
r.sc3s"|]\}}|�kr|ndVqdS)rNr)rr	r
)rrr
r2s)r)
rrrrr rr+rrr,rrr)
rrr-rr"r.r&r'r/r0r)rrr
�_append_ramps r2cs�|dkr|S�dkr t||��S�dk	r:�|j�kr:d�t��fdd�t|j�D��}t�fdd�t|j�D��}||j�d��|�}tj|j|�d�|f�d�S)aS
    Prepend `pad_amt` maximum values along `axis`.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : int
        Amount of padding to prepend.
    num : int
        Depth into `arr` along `axis` to calculate maximum.
        Range: [1, `arr.shape[axis]`] or None (entire axis)
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, with `pad_amt` values appended along `axis`. The
        prepended region is the maximum of the first `num` values along
        `axis`.

    rrNc3s*|]"\}}|�krtd�nt��VqdS)N)r%)rr	r
)r�numrr
rgsz_prepend_max.<locals>.<genexpr>c3s"|]\}}|�kr|ndVqdS)rNr)rr	r
)rrr
rks)r)	r)rrr�maxrrrr)rrr3r�	max_slicer'�	max_chunkr)rr3r
�_prepend_maxBsr7cs�|dkr|S�dkr t||��S�dk	r:�|j�kr:d�|j�d��dk	rrt���fdd�t|j�D��}ntdd�|jD��}t�fdd�t|j�D��}||j�d��|�}tj||j|�d�f�d�S)	a_
    Pad one `axis` of `arr` with the maximum of the last `num` elements.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : int
        Amount of padding to append.
    num : int
        Depth into `arr` along `axis` to calculate maximum.
        Range: [1, `arr.shape[axis]`] or None (entire axis)
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, with `pad_amt` values appended along `axis`. The
        appended region is the maximum of the final `num` values along `axis`.

    rrNc3s2|]*\}}|�krtd�nt���d�VqdS)Nr)r%)rr	r
)rr-r3rr
r�sz_append_max.<locals>.<genexpr>css|]}td�VqdS)N)r%)rr
rrr
r�sc3s"|]\}}|�kr|ndVqdS)rNr)rr	r
)rrr
r�s)r)	r*rrrr4rrrr)rrr3rr5r'r6r)rr-r3r
�_append_maxvs$r8cs�|dkr|S�dkr t||��S�dk	r:�|j�kr:d�t��fdd�t|j�D��}t�fdd�t|j�D��}||����|�}t||j�tj	|�
|���|j�|f�d�S)aC
    Prepend `pad_amt` mean values along `axis`.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : int
        Amount of padding to prepend.
    num : int
        Depth into `arr` along `axis` to calculate mean.
        Range: [1, `arr.shape[axis]`] or None (entire axis)
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, with `pad_amt` values prepended along `axis`. The
        prepended region is the mean of the first `num` values along `axis`.

    rrNc3s*|]"\}}|�krtd�nt��VqdS)N)r%)rr	r
)rr3rr
r�sz _prepend_mean.<locals>.<genexpr>c3s"|]\}}|�kr|ndVqdS)rNr)rr	r
)rrr
r�s)r)r)rrr�meanrrrrrrr )rrr3r�
mean_slicer'�
mean_chunkr)rr3r
�
_prepend_mean�sr<cs�|dkr|S�dkr t||��S�dk	r:�|j�kr:d�|j�d��dk	rrt���fdd�t|j�D��}ntdd�|jD��}t�fdd�t|j�D��}||j�d��|�}t||j�tj	||�
|���|j�f�d�S)	aB
    Append `pad_amt` mean values along `axis`.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : int
        Amount of padding to append.
    num : int
        Depth into `arr` along `axis` to calculate mean.
        Range: [1, `arr.shape[axis]`] or None (entire axis)
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, with `pad_amt` values appended along `axis`. The
        appended region is the maximum of the final `num` values along `axis`.

    rrNc3s2|]*\}}|�krtd�nt���d�VqdS)Nr)r%)rr	r
)rr-r3rr
r	sz_append_mean.<locals>.<genexpr>css|]}td�VqdS)N)r%)rr
rrr
rsc3s"|]\}}|�kr|ndVqdS)rNr)rr	r
)rrr
rs)r)r*rrrr9rrrrrrr )rrr3rr:r'r;r)rr-r3r
�_append_mean�s&r=cs�|dkr|S�dkr t||��S�dk	r:�|j�kr:d�t��fdd�t|j�D��}t�fdd�t|j�D��}tj||�d��|�}t||j�tj	|�
|���|j�|f�d�S)aI
    Prepend `pad_amt` median values along `axis`.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : int
        Amount of padding to prepend.
    num : int
        Depth into `arr` along `axis` to calculate median.
        Range: [1, `arr.shape[axis]`] or None (entire axis)
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, with `pad_amt` values prepended along `axis`. The
        prepended region is the median of the first `num` values along `axis`.

    rrNc3s*|]"\}}|�krtd�nt��VqdS)N)r%)rr	r
)rr3rr
r?sz_prepend_med.<locals>.<genexpr>c3s"|]\}}|�kr|ndVqdS)rNr)rr	r
)rrr
rCs)r)r)rrrr�medianrrrrrr )rrr3r�	med_slicer'�	med_chunkr)rr3r
�_prepend_medsrAcs�|dkr|S�dkr t||��S�dk	r:�|j�kr:d�|j�d��dk	rrt���fdd�t|j�D��}ntdd�|jD��}t�fdd�t|j�D��}tj||�d��|�}t||j�tj	||�
|���|j�f�d�S)	aE
    Append `pad_amt` median values along `axis`.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : int
        Amount of padding to append.
    num : int
        Depth into `arr` along `axis` to calculate median.
        Range: [1, `arr.shape[axis]`] or None (entire axis)
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, with `pad_amt` values appended along `axis`. The
        appended region is the median of the final `num` values along `axis`.

    rrNc3s2|]*\}}|�krtd�nt���d�VqdS)Nr)r%)rr	r
)rr-r3rr
rvsz_append_med.<locals>.<genexpr>css|]}td�VqdS)N)r%)rr
rrr
rysc3s"|]\}}|�kr|ndVqdS)rNr)rr	r
)rrr
r|s)r)r*rrrrr>rrrrrr )rrr3rr?r'r@r)rr-r3r
�_append_medOs&rBcs�|dkr|S�dkr t||��S�dk	r:�|j�kr:d�t��fdd�t|j�D��}t�fdd�t|j�D��}||j�d��|�}tj|j|�d�|f�d�S)aT
    Prepend `pad_amt` minimum values along `axis`.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : int
        Amount of padding to prepend.
    num : int
        Depth into `arr` along `axis` to calculate minimum.
        Range: [1, `arr.shape[axis]`] or None (entire axis)
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, with `pad_amt` values prepended along `axis`. The
        prepended region is the minimum of the first `num` values along
        `axis`.

    rrNc3s*|]"\}}|�krtd�nt��VqdS)N)r%)rr	r
)rr3rr
r�sz_prepend_min.<locals>.<genexpr>c3s"|]\}}|�kr|ndVqdS)rNr)rr	r
)rrr
r�s)r)	r)rrr�minrrrr)rrr3r�	min_slicer'�	min_chunkr)rr3r
�_prepend_min�srFcs�|dkr|S�dkr t||��S�dk	r:�|j�kr:d�|j�d��dk	rrt���fdd�t|j�D��}ntdd�|jD��}t�fdd�t|j�D��}||j�d��|�}tj||j|�d�f�d�S)	aG
    Append `pad_amt` median values along `axis`.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : int
        Amount of padding to append.
    num : int
        Depth into `arr` along `axis` to calculate minimum.
        Range: [1, `arr.shape[axis]`] or None (entire axis)
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, with `pad_amt` values appended along `axis`. The
        appended region is the minimum of the final `num` values along `axis`.

    rrNc3s2|]*\}}|�krtd�nt���d�VqdS)Nr)r%)rr	r
)rr-r3rr
r�sz_append_min.<locals>.<genexpr>css|]}td�VqdS)N)r%)rr
rrr
r�sc3s"|]\}}|�kr|ndVqdS)rNr)rr	r
)rrr
r�s)r)	r*rrrrCrrrr)rrr3rrDr'rEr)rr-r3r
�_append_min�s$rGcs��ddkr�ddkr|St��fdd�t|j�D��}||}t�fdd�t|j�D��}�ddkrt|�|�}d|kr��ddkr�t�fdd�t|j�D��}||�|�}d||}~|j��dd�|j�d�t���fd	d�t|j�D��}t�fd
d�t|j�D��}	|||	}
�ddk�rD|
�|�}
d|k�r�t�fdd�t|j�D��}||�|�}d||
}
~tj|||
f�d�S)
a�
    Pad `axis` of `arr` by reflection.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : tuple of ints, length 2
        Padding to (prepend, append) along `axis`.
    method : str
        Controls method of reflection; options are 'even' or 'odd'.
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, with `pad_amt[0]` values prepended and `pad_amt[1]`
        values appended along `axis`. Both regions are padded with reflected
        values from the original array.

    Notes
    -----
    This algorithm does not pad with repetition, i.e. the edges are not
    repeated in the reflection. For that behavior, use `mode='symmetric'`.

    The modes 'reflect', 'symmetric', and 'wrap' must be padded with a
    single function, lest the indexing tricks in non-integer multiples of the
    original shape would violate repetition in the final iteration.

    rrc3s2|]*\}}|�krtd�nt�ddd�VqdS)Nrr)r%)rr	r
)rrrr
rsz_pad_ref.<locals>.<genexpr>c3s"|]\}}|�kr|ndVqdS)rNr)rr	r
)rrr
r"s�oddc3s&|]\}}|�krtd�ndVqdS)Nr)r%)rr	r
)rrr
r)s�c3s,|]$\}}|�krtd�nt���VqdS)N)r%)rr	r
)rr-�startrr
r5sc3s.|]&\}}|�krtd�n
tddd�VqdS)Nr)r%)rr	r
)rrr
r7sc3s&|]\}}|�krtd�ndVqdS)Nr)r%)rr	r
)rrr
r?s)r)rrrrrr)rr�methodrZ	ref_sliceZ
ref_chunk1r'�edge_slice1�
edge_chunk�rev_idxZ
ref_chunk2�edge_slice2r)rr-rrJr
�_pad_ref�s>!


rPcs��ddkr�ddkr|St��fdd�t|j�D��}t�fdd�t|j�D��}|||}t�fdd�t|j�D��}�ddkr�|�|�}d|kr�ddkr�t�fdd�t|j�D��}||�|�}	d	|	|}~	|j��d�|j��t���fd
d�t|j�D��}|||}
�ddk�r@|
�|�}
d|k�r�t�fdd�t|j�D��}||�|�}	d	|	|
}
~	tj|||
f�d�S)
a�
    Pad `axis` of `arr` by symmetry.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : tuple of ints, length 2
        Padding to (prepend, append) along `axis`.
    method : str
        Controls method of symmetry; options are 'even' or 'odd'.
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, with `pad_amt[0]` values prepended and `pad_amt[1]`
        values appended along `axis`. Both regions are padded with symmetric
        values from the original array.

    Notes
    -----
    This algorithm DOES pad with repetition, i.e. the edges are repeated.
    For padding without repeated edges, use `mode='reflect'`.

    The modes 'reflect', 'symmetric', and 'wrap' must be padded with a
    single function, lest the indexing tricks in non-integer multiples of the
    original shape would violate repetition in the final iteration.

    rrc3s0|](\}}|�krtd�ntd�d�VqdS)Nr)r%)rr	r
)rrrr
rqsz_pad_sym.<locals>.<genexpr>c3s.|]&\}}|�krtd�n
tddd�VqdS)Nr)r%)rr	r
)rrr
rssc3s"|]\}}|�kr|ndVqdS)rNr)rr	r
)rrr
rxsrHc3s&|]\}}|�krtd�ndVqdS)Nr)r%)rr	r
)rrr
rsrIc3s,|]$\}}|�krtd�nt���VqdS)N)r%)rr	r
)rr-rJrr
r�sc3s&|]\}}|�krtd�ndVqdS)Nr)r%)rr	r
)rrr
r�s)r)rrrrrr)rrrKrZ	sym_slicerNZ
sym_chunk1r'rLrMZ
sym_chunk2rOr)rr-rrJr
�_pad_symIs>!



rQcs��ddkr�ddkr|S|j��d�|j��t���fdd�t|j�D��}||}t�fdd�t|j�D��}�ddkr�|�|�}t��fdd�t|j�D��}||}�ddkr�|�|�}tj|||f�d�S)a1
    Pad `axis` of `arr` via wrapping.

    Parameters
    ----------
    arr : ndarray
        Input array of arbitrary shape.
    pad_amt : tuple of ints, length 2
        Padding to (prepend, append) along `axis`.
    axis : int
        Axis along which to pad `arr`.

    Returns
    -------
    padarr : ndarray
        Output array, with `pad_amt[0]` values prepended and `pad_amt[1]`
        values appended along `axis`. Both regions are padded wrapped values
        from the opposite end of `axis`.

    Notes
    -----
    This method of padding is also known as 'tile' or 'tiling'.

    The modes 'reflect', 'symmetric', and 'wrap' must be padded with a
    single function, lest the indexing tricks in non-integer multiples of the
    original shape would violate repetition in the final iteration.

    rrc3s,|]$\}}|�krtd�nt���VqdS)N)r%)rr	r
)rr-rJrr
r�sz_pad_wrap.<locals>.<genexpr>c3s"|]\}}|�kr|ndVqdS)rNr)rr	r
)rrr
r�sc3s0|](\}}|�krtd�ntd�d�VqdS)Nrr)r%)rr	r
)rrrr
r�s)r)rrrrrr)rrrZ
wrap_sliceZwrap_chunk1r'Zwrap_chunk2r)rr-rrJr
�	_pad_wrap�s"


rRTcCs�|j}|dkrd|St�|�}yt�||df�}Wn&tk
rZd}t||f��YnX|dkrtt�|��t�}tdd�|�	�D��S)aZ
    Private function which does some checks and normalizes the possibly
    much simpler representations of 'pad_width', 'stat_length',
    'constant_values', 'end_values'.

    Parameters
    ----------
    narray : ndarray
        Input ndarray
    shape : {sequence, array_like, float, int}, optional
        The width of padding (pad_width), the number of elements on the
        edge of the narray used for statistics (stat_length), the constant
        value(s) to use when filling padded regions (constant_values), or the
        endpoint target(s) for linear ramps (end_values).
        ((before_1, after_1), ... (before_N, after_N)) unique number of
        elements for each axis where `N` is rank of `narray`.
        ((before, after),) yields same before and after constants for each
        axis.
        (constant,) or val is a shortcut for before = after = constant for
        all axes.
    cast_to_int : bool, optional
        Controls if values in ``shape`` will be rounded and cast to int
        before being returned.

    Returns
    -------
    normalized_shape : tuple of tuples
        val                               => ((val, val), (val, val), ...)
        [[val1, val2], [val3, val4], ...] => ((val1, val2), (val3, val4), ...)
        ((val1, val2), (val3, val4), ...) => no change
        [[val1, val2], ]                  => ((val1, val2), (val1, val2), ...)
        ((val1, val2), )                  => ((val1, val2), (val1, val2), ...)
        [[val ,     ], ]                  => ((val, val), (val, val), ...)
        ((val ,     ), )                  => ((val, val), (val, val), ...)

    N))NNrIz/Unable to create correctly shaped tuple from %sTcss|]}t|�VqdS)N)r)rrrrr
rsz#_normalize_shape.<locals>.<genexpr>)
�ndimr�asarrayZbroadcast_to�
ValueErrorrr �intr�tolist)Zndarrayr�cast_to_intZndimsZ	shape_arr�fmtrrr
�_normalize_shape�s%
rZcCsbt||�}xR|D]J}dd�|D�}dd�|D�}|ddksH|ddkrd}t||f��qW|S)a�
    Private function which does some checks and reformats pad_width and
    stat_length using _normalize_shape.

    Parameters
    ----------
    narray : ndarray
        Input ndarray
    number_elements : {sequence, int}, optional
        The width of padding (pad_width) or the number of elements on the edge
        of the narray used for statistics (stat_length).
        ((before_1, after_1), ... (before_N, after_N)) unique number of
        elements for each axis.
        ((before, after),) yields same before and after constants for each
        axis.
        (constant,) or int is a shortcut for before = after = constant for all
        axes.

    Returns
    -------
    _validate_lengths : tuple of tuples
        int                               => ((int, int), (int, int), ...)
        [[int1, int2], [int3, int4], ...] => ((int1, int2), (int3, int4), ...)
        ((int1, int2), (int3, int4), ...) => no change
        [[int1, int2], ]                  => ((int1, int2), (int1, int2), ...)
        ((int1, int2), )                  => ((int1, int2), (int1, int2), ...)
        [[int ,     ], ]                  => ((int, int), (int, int), ...)
        ((int ,     ), )                  => ((int, int), (int, int), ...)

    cSsg|]}|dkrdn|�qS)Nrr)rr
rrr
�
<listcomp>:sz%_validate_lengths.<locals>.<listcomp>cSsg|]}|dkrdnd�qS)rrrr)rr
rrr
r[;srrz"%s cannot contain negative values.)rZrU)�narrayZnumber_elementsZnormshpr	ZchkrYrrr
�_validate_lengthss

r]cs�t���jjdkstd��t�|��t����dggdgdgdgdgdgdgdggd�
}dd	d	d
d�}t|tjj	��rx,|D]$}|||kr|t
d|||f��q|Wx ||D]}|�|||�q�Wx�|D]<}|dkr�t�||�||<|d
kr�t�||dd�||<q�Wn�|}	t
t�j��}
�fdd�|
D�}��fdd�|
D�}t��j�|}
t�|
�j�}�||<x&|
D]}t�|	||�|||��qrW|S���}|dk�r�xHtt�|d��D]2\}\\}}\}}t||||�}t||||�}�q�W�n�|dk�r:x2t��D]&\}\}}t|||�}t|||�}�qW�nX|dk�r�xHtt�|d��D]2\}\\}}\}}t||||�}t||||�}�qXW�n|dk�r�xHtt�|d��D]2\}\\}}\}}t||||�}t||||�}�q�W�n�|dk�rBxHtt�|d��D]2\}\\}}\}}t||||�}t||||�}�qW�nP|dk�r�xHtt�|d��D]2\}\\}}\}}t ||||�}t!||||�}�q`W�n�|dk�r�xHtt�|d��D]2\}\\}}\}}t"||||�}t#||||�}�q�W�n�|dk�r,�x�t��D�]\}\}}�j|d	k�rL|d	k�s:|d	k�rt
d�$|����q|d	k�s`|d	k�r�|j|dk�r�t|||�}t|||�}�q|d}|j|d}xl||k�s�||k�rt%||||�}t%||||�}t&|||f||�}||8}||8}|||7}�q�Wt&|||f||�}�qW�nf|dk�r�x�t��D]�\}\}}|d}|j|}xl||k�st||k�r�t%||||�}t%||||�}t'|||f||�}||8}||8}|||7}�q`Wt'|||f||�}�q@Wn�|dk�r�x�t��D]�\}\}}|j|}xj||k�s&||k�rzt%||||�}t%||||�}t(|||f|�}||8}||8}|||7}�qWt(|||f|�}�q�W|S)a�
    Pads an array.

    Parameters
    ----------
    array : array_like of rank N
        Input array
    pad_width : {sequence, array_like, int}
        Number of values padded to the edges of each axis.
        ((before_1, after_1), ... (before_N, after_N)) unique pad widths
        for each axis.
        ((before, after),) yields same before and after pad for each axis.
        (pad,) or int is a shortcut for before = after = pad width for all
        axes.
    mode : str or function
        One of the following string values or a user supplied function.

        'constant'
            Pads with a constant value.
        'edge'
            Pads with the edge values of array.
        'linear_ramp'
            Pads with the linear ramp between end_value and the
            array edge value.
        'maximum'
            Pads with the maximum value of all or part of the
            vector along each axis.
        'mean'
            Pads with the mean value of all or part of the
            vector along each axis.
        'median'
            Pads with the median value of all or part of the
            vector along each axis.
        'minimum'
            Pads with the minimum value of all or part of the
            vector along each axis.
        'reflect'
            Pads with the reflection of the vector mirrored on
            the first and last values of the vector along each
            axis.
        'symmetric'
            Pads with the reflection of the vector mirrored
            along the edge of the array.
        'wrap'
            Pads with the wrap of the vector along the axis.
            The first values are used to pad the end and the
            end values are used to pad the beginning.
        <function>
            Padding function, see Notes.
    stat_length : sequence or int, optional
        Used in 'maximum', 'mean', 'median', and 'minimum'.  Number of
        values at edge of each axis used to calculate the statistic value.

        ((before_1, after_1), ... (before_N, after_N)) unique statistic
        lengths for each axis.

        ((before, after),) yields same before and after statistic lengths
        for each axis.

        (stat_length,) or int is a shortcut for before = after = statistic
        length for all axes.

        Default is ``None``, to use the entire axis.
    constant_values : sequence or int, optional
        Used in 'constant'.  The values to set the padded values for each
        axis.

        ((before_1, after_1), ... (before_N, after_N)) unique pad constants
        for each axis.

        ((before, after),) yields same before and after constants for each
        axis.

        (constant,) or int is a shortcut for before = after = constant for
        all axes.

        Default is 0.
    end_values : sequence or int, optional
        Used in 'linear_ramp'.  The values used for the ending value of the
        linear_ramp and that will form the edge of the padded array.

        ((before_1, after_1), ... (before_N, after_N)) unique end values
        for each axis.

        ((before, after),) yields same before and after end values for each
        axis.

        (constant,) or int is a shortcut for before = after = end value for
        all axes.

        Default is 0.
    reflect_type : {'even', 'odd'}, optional
        Used in 'reflect', and 'symmetric'.  The 'even' style is the
        default with an unaltered reflection around the edge value.  For
        the 'odd' style, the extented part of the array is created by
        subtracting the reflected values from two times the edge value.

    Returns
    -------
    pad : ndarray
        Padded array of rank equal to `array` with shape increased
        according to `pad_width`.

    Notes
    -----
    .. versionadded:: 1.7.0

    For an array with rank greater than 1, some of the padding of later
    axes is calculated from padding of previous axes.  This is easiest to
    think about with a rank 2 array where the corners of the padded array
    are calculated by using padded values from the first axis.

    The padding function, if used, should return a rank 1 array equal in
    length to the vector argument with padded values replaced. It has the
    following signature::

        padding_func(vector, iaxis_pad_width, iaxis, **kwargs)

    where

        vector : ndarray
            A rank 1 array already padded with zeros.  Padded values are
            vector[:pad_tuple[0]] and vector[-pad_tuple[1]:].
        iaxis_pad_width : tuple
            A 2-tuple of ints, iaxis_pad_width[0] represents the number of
            values padded at the beginning of vector where
            iaxis_pad_width[1] represents the number of values padded at
            the end of vector.
        iaxis : int
            The axis currently being calculated.
        kwargs : misc
            Any keyword arguments the function requires.

    Examples
    --------
    >>> a = [1, 2, 3, 4, 5]
    >>> np.lib.pad(a, (2,3), 'constant', constant_values=(4, 6))
    array([4, 4, 1, 2, 3, 4, 5, 6, 6, 6])

    >>> np.lib.pad(a, (2, 3), 'edge')
    array([1, 1, 1, 2, 3, 4, 5, 5, 5, 5])

    >>> np.lib.pad(a, (2, 3), 'linear_ramp', end_values=(5, -4))
    array([ 5,  3,  1,  2,  3,  4,  5,  2, -1, -4])

    >>> np.lib.pad(a, (2,), 'maximum')
    array([5, 5, 1, 2, 3, 4, 5, 5, 5])

    >>> np.lib.pad(a, (2,), 'mean')
    array([3, 3, 1, 2, 3, 4, 5, 3, 3])

    >>> np.lib.pad(a, (2,), 'median')
    array([3, 3, 1, 2, 3, 4, 5, 3, 3])

    >>> a = [[1, 2], [3, 4]]
    >>> np.lib.pad(a, ((3, 2), (2, 3)), 'minimum')
    array([[1, 1, 1, 2, 1, 1, 1],
           [1, 1, 1, 2, 1, 1, 1],
           [1, 1, 1, 2, 1, 1, 1],
           [1, 1, 1, 2, 1, 1, 1],
           [3, 3, 3, 4, 3, 3, 3],
           [1, 1, 1, 2, 1, 1, 1],
           [1, 1, 1, 2, 1, 1, 1]])

    >>> a = [1, 2, 3, 4, 5]
    >>> np.lib.pad(a, (2, 3), 'reflect')
    array([3, 2, 1, 2, 3, 4, 5, 4, 3, 2])

    >>> np.lib.pad(a, (2, 3), 'reflect', reflect_type='odd')
    array([-1,  0,  1,  2,  3,  4,  5,  6,  7,  8])

    >>> np.lib.pad(a, (2, 3), 'symmetric')
    array([2, 1, 1, 2, 3, 4, 5, 5, 4, 3])

    >>> np.lib.pad(a, (2, 3), 'symmetric', reflect_type='odd')
    array([0, 1, 1, 2, 3, 4, 5, 5, 6, 7])

    >>> np.lib.pad(a, (2, 3), 'wrap')
    array([4, 5, 1, 2, 3, 4, 5, 1, 2, 3])

    >>> def padwithtens(vector, pad_width, iaxis, kwargs):
    ...     vector[:pad_width[0]] = 10
    ...     vector[-pad_width[1]:] = 10
    ...     return vector

    >>> a = np.arange(6)
    >>> a = a.reshape((2, 3))

    >>> np.lib.pad(a, 2, padwithtens)
    array([[10, 10, 10, 10, 10, 10, 10],
           [10, 10, 10, 10, 10, 10, 10],
           [10, 10,  0,  1,  2, 10, 10],
           [10, 10,  3,  4,  5, 10, 10],
           [10, 10, 10, 10, 10, 10, 10],
           [10, 10, 10, 10, 10, 10, 10]])
    r	z%`pad_width` must be of integral type.�constant_values�
end_values�stat_length�reflect_type)
�constant�edge�linear_ramp�maximumr9r>�minimum�reflect�	symmetric�wrapNrZeven)r`r^r_raz%%s keyword not in allowed keywords %s)r_r^F)rXcsg|]}t��|��qSr)r�sum)rr	)�	pad_widthrr
r[>szpad.<locals>.<listcomp>cs0g|](}t�|d�|d�j|��qS)r)r%r)rr	)r\rkrr
r[?srbrcrdrer9r>rfrgz:There aren't any elements to reflect in axis {} of `array`rrhri))rrTr�kind�	TypeError�arrayr]�
isinstance�compat�
basestringrU�
setdefaultrZ�list�rangerSrrZapply_along_axis�copyr�zipr#r$r)r*r1r2r7r8r<r=rArBrFrG�formatrCrPrQrR)rnrk�mode�kwargsZ
allowedkwargs�
kwdefaults�key�kwr	�functionZrankZtotal_dim_increaseZ
offset_slicesZ	new_shapeZnewmatZiaxisrZ
pad_beforeZ	pad_afterZ
before_valZ	after_valZchunk_beforeZchunk_afterrKZsafe_padZ
pad_iter_bZ
pad_iter_ar)r\rkr
rFsF






&

&
&
&
&
&







)F)r)r)r)r)r)r)r)r)r)r)r)r)r)r)r)r)r)T)�__doc__�
__future__rrr�numpyr�__all__rrr#r$r)r*r1r2r7r8r<r=rArBrFrGrPrQrRrZr]rrrrr
�<module>s2
+
"
"
!
"
7
7
4
8
4
9
4
9
4
8
U
T
@
<-

Youez - 2016 - github.com/yon3zu
LinuXploit