ó °¿v]c@`s‰dZddlmZmZmZddlZddlmZdgZ e d„Z d„Z d„Z d „Zd „Zd „Zd „Zd d„Zd d„Zd d„Zd d„Zd d„Zd d„Zd d„Zd d„Zd d„Zd d„Zd d„Zd d„Zd d„Zd d„Zd d„Z d d„Z!d d„Z"e d„Z#d „Z$ee$d!d"ƒd#„ƒZ%dS($sl The arraypad module contains a group of functions to pad values onto the edges of an n-dimensional array. i(tdivisiontabsolute_importtprint_functionN(tarray_function_dispatchtpadc`s¿t‡‡fd†t|jƒDƒƒ}|sKtjdˆˆdƒ}ntjˆˆddƒ}|j|ƒ}xEtˆƒD]7\}}|j||kr€|j|d|ƒ}q€q€W|S(s— 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. c3`s1|]'\}}|ˆkr!dnˆˆVqdS(iN((t.0titx(taxistshape(sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pys 1siiiÿÿÿÿR(ttuplet enumerateR tnptarangetreshapetrepeat(tarrR Rtreverset initshapetpadarrRtdim((RR sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt_arange_ndarrayscC`s,tj|tjƒr(|jd|ƒndS(s Rounds arr inplace if destination dtype is integer. Parameters ---------- arr : ndarray Input array. dtype : dtype The dtype of the destination array. toutN(R t issubdtypetintegertround(Rtdtype((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt_round_ifneeded>s cC`s4tdƒf}|||f|t|ƒ|dS(sT Construct a slice tuple the length of shape, with sl at the specified axis iN(tslicetNonetlen(R tslRt slice_tup((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt_slice_at_axisNscC`st|td|ƒd|ƒS(sA Construct a slice tuple to take the first n elements along axis iR(R!R(R tnR((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _slice_firstVscC`s*||}t|t|||ƒd|ƒS(s@ Construct a slice tuple to take the last n elements along axis R(R!R(R R"RR((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _slice_last[s cC`s+tj|j|jdtƒ|fd|ƒS(NtcopyR(R t concatenatetastypeRtFalse(Rt pad_chunkR((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _do_prependascC`s+tj||j|jdtƒfd|ƒS(NR%R(R R&R'RR((RR)R((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _do_appendfsiÿÿÿÿc`s]ˆdkr|St‡‡fd†t|jƒDƒƒ}t|tj||d|jƒˆƒS(s 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`. ic3`s-|]#\}}|ˆkr!|nˆVqdS(N((RRR(Rtpad_amt(sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pys ƒsR(R R R R*R tfullR(RR,tvalRtpadshape((RR,sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt_prepend_constks  c`s]ˆdkr|St‡‡fd†t|jƒDƒƒ}t|tj||d|jƒˆƒS(s 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`. ic3`s-|]#\}}|ˆkr!|nˆVqdS(N((RRR(RR,(sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pys  sR(R R R R+R R-R(RR,R.RR/((RR,sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _append_constˆs  cC`sQ|dkr|St|jdd|ƒ}||}t||j|d|ƒ|ƒS(s 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`. iiR(R#R R*R(RR,Rt edge_slicetedge_arr((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _prepend_edge¦s   cC`sQ|dkr|St|jdd|ƒ}||}t||j|d|ƒ|ƒS(s— 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`. iiR(R$R R+R(RR,RR2R3((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _append_edgeÁs   c `sÒˆdkr|St‡‡fd†t|jƒDƒƒ}t||ˆdtƒjtjƒ}t|jddˆƒ}||j ˆˆƒ}||t ˆƒ}||}||7}t ||j ƒt ||ˆƒS(sF 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`. ic3`s-|]#\}}|ˆkr!|nˆVqdS(N((RRR(RR,(sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pys øsRiR(R R R RtTrueR'R tfloat64R#RtfloatRRR*( RR,tendRR/tramp_arrR2tedge_padtslope((RR,sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _prepend_rampÝs   c `sÒˆdkr|St‡‡fd†t|jƒDƒƒ}t||ˆdtƒjtjƒ}t|jddˆƒ}||j ˆˆƒ}||t ˆƒ}||}||7}t ||j ƒt ||ˆƒS(sB 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`. ic3`s-|]#\}}|ˆkr!|nˆVqdS(N((RRR(RR,(sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pys *sRiR(R R R RR(R'R R7R$RR8RRR+( RR,R9RR/R:R2R;R<((RR,sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _append_ramps   cC`sª|dkr|S|dkr,t|||ƒS|dk rW||j|krWd}qWnt|j|d|ƒ}||jd|dtƒ}t||j|d|ƒ|ƒS(sS 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`. iiRtkeepdimsN(R4RR R#tmaxR6R*R(RR,tnumRt max_slicet max_chunk((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _prepend_maxAs    cC`sÒ|dkr|S|dkr,t|||ƒS|dk rW||j|krWd}qWn|dk r~t|j|d|ƒ}ntd„|jDƒƒ}||jd|dtƒ}t||j|d|ƒ|ƒS(s_ 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`. iiRcs`s|]}tdƒVqdS(N(RR(RR((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pys –sR?N( R5RR R$R R@R6R+R(RR,RARRBRC((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _append_maxos     cC`s·|dkr|S|dkr,t|||ƒS|dk rW||j|krWd}qWnt|j|d|ƒ}||j|dtƒ}t||jƒt||j ||ƒd|ƒS(sC 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`. iiRR?N( R4RR R#tmeanR6RRR*R(RR,RARt mean_slicet mean_chunk((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _prepend_meanŸs    cC`sâ|dkr|S|dkr,t|||ƒS|dk rW||j|krWd}qWn|dk r~t|j|d|ƒ}ntd„|jDƒƒ}||jd|dtƒ}t||jƒt ||j ||ƒd|ƒS(sB 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`. iiRcs`s|]}tdƒVqdS(N(RR(RR((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pys ôsR?N( R5RR R$R RFR6RRR+R(RR,RARRGRH((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _append_meanÍs     cC`s½|dkr|S|dkr,t|||ƒS|dk rW||j|krWd}qWnt|j|d|ƒ}tj||d|dtƒ}t||jƒt ||j ||ƒd|ƒS(sI 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`. iiRR?N( R4RR R#R tmedianR6RRR*R(RR,RARt med_slicet med_chunk((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _prepend_medþs    cC`så|dkr|S|dkr,t|||ƒS|dk rW||j|krWd}qWn|dk r~t|j|d|ƒ}ntd„|jDƒƒ}tj||d|dtƒ}t||j ƒt ||j ||ƒd|ƒS(sE 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`. iiRcs`s|]}tdƒVqdS(N(RR(RR((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pys SsR?N( R5RR R$R R RKR6RRR+R(RR,RARRLRM((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _append_med,s     cC`sª|dkr|S|dkr,t|||ƒS|dk rW||j|krWd}qWnt|j|d|ƒ}||jd|dtƒ}t||j||ƒd|ƒS(sT 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`. iiRR?N(R4RR R#tminR6R*R(RR,RARt min_slicet min_chunk((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _prepend_min]s    cC`sÒ|dkr|S|dkr,t|||ƒS|dk rW||j|krWd}qWn|dk r~t|j|d|ƒ}ntd„|jDƒƒ}||jd|dtƒ}t||j||ƒd|ƒS(sG 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`. iiRcs`s|]}tdƒVqdS(N(RR(RR((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pys ²sR?N( R5RR R$R RPR6R+R(RR,RARRQRR((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _append_min‹s     c C`sƒ|ddkr$|ddkr$|St|jt|dddƒd|ƒ}||}d|kr¨|ddkr¨t|jdd|ƒ}||}d||}~n|j||dd}|j|d} t|jt|| ƒd|ƒ}t|jtdddƒd|ƒ} ||| } d|krgt|jdd|ƒ} || }d|| } ~ntj||| fd|ƒS(sÙ 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. iiiÿÿÿÿRtoddiN(R!R RR#RR$R R&( RR,tmethodRt ref_slicet ref_chunk1t edge_slice1t edge_chunktstartR9trev_idxt ref_chunk2t edge_slice2((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt_pad_ref»s(! (  !$  c C`sL|ddkr$|ddkr$|St|j|dd|ƒ}t|jtdddƒd|ƒ}|||}d|krÄ|ddkrÄt|jdd|ƒ}||}d||}~nt|j|dd|ƒ}|||} d|kr0t|jdd|ƒ} || }d|| } ~ntj||| fd|ƒS(sÊ 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. iiRiÿÿÿÿRUiN(R#R R!RRR$R R&( RR,RVRt sym_sliceR\t sym_chunk1RYRZt sym_chunk2R^((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt_pad_syms$! $   cC`sŒ|ddkr$|ddkr$|St|j|dd|ƒ}||}t|j|dd|ƒ}||}tj|||fd|ƒS(s1 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. iiR(R$R R#R R&(RR,Rt wrap_slicet wrap_chunk1t wrap_chunk2((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _pad_wrapFs   cC`so|dkrd |Stj|ƒ}|rMtj|ƒjtjdtƒ}n|jdkr,|jdkr±|j ƒ}|r˜|dkr˜t dƒ‚n|d|dff|S|jdkr,|j d kr,|j ƒ}|r|ddks|ddkrt dƒ‚n|d|dff|Sn|rS|j ƒdkrSt dƒ‚ntj ||dfƒjƒS( s8 Broadcast `x` to an array with the shape (`ndim`, 2). A helper function for `pad` that prepares and validates arguments like `pad_width` for iteration in pairs. Parameters ---------- x : {None, scalar, array-like} The object to broadcast to the shape (`ndim`, 2). ndim : int Number of pairs the broadcasted `x` will have. as_index : bool, optional If `x` is not None, try to round each element of `x` to an integer (dtype `np.intp`) and ensure every element is positive. Returns ------- pairs : nested iterables, shape (`ndim`, 2) The broadcasted version of `x`. Raises ------ ValueError If `as_index` is True and `x` contains negative elements. Or if `x` is not broadcastable to the shape (`ndim`, 2). R%iiis#index can't contain negative valuesiN(NN((NN(ii(RR tarrayRR'tintpR(tndimtsizetravelt ValueErrorR RPt broadcast_tottolist(RRjtas_index((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt _as_pairsys& $  &cK`s|fS(N((Rht pad_widthtmodetkwargs((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyt_pad_dispatcherÀstmoduletnumpyc `s tjˆƒjjdks*tdƒ‚ntj|ƒ‰tˆˆjdtƒ‰i dgd6gd6dgd6d gd 6d gd 6d gd 6d gd 6dgd6dgd6gd6}idd 6dd6dd6dd6}t |tj j ƒr¿x;|D]3}|||krót d|||fƒ‚qóqóWx&||D]}|j|||ƒq5Wx3|D]^}|d krt||ˆjdtƒ|| 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 extended 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 : dict Any keyword arguments the function requires. Examples -------- >>> a = [1, 2, 3, 4, 5] >>> np.pad(a, (2,3), 'constant', constant_values=(4, 6)) array([4, 4, 1, 2, 3, 4, 5, 6, 6, 6]) >>> np.pad(a, (2, 3), 'edge') array([1, 1, 1, 2, 3, 4, 5, 5, 5, 5]) >>> np.pad(a, (2, 3), 'linear_ramp', end_values=(5, -4)) array([ 5, 3, 1, 2, 3, 4, 5, 2, -1, -4]) >>> np.pad(a, (2,), 'maximum') array([5, 5, 1, 2, 3, 4, 5, 5, 5]) >>> np.pad(a, (2,), 'mean') array([3, 3, 1, 2, 3, 4, 5, 3, 3]) >>> np.pad(a, (2,), 'median') array([3, 3, 1, 2, 3, 4, 5, 3, 3]) >>> a = [[1, 2], [3, 4]] >>> np.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.pad(a, (2, 3), 'reflect') array([3, 2, 1, 2, 3, 4, 5, 4, 3, 2]) >>> np.pad(a, (2, 3), 'reflect', reflect_type='odd') array([-1, 0, 1, 2, 3, 4, 5, 6, 7, 8]) >>> np.pad(a, (2, 3), 'symmetric') array([2, 1, 1, 2, 3, 4, 5, 5, 4, 3]) >>> np.pad(a, (2, 3), 'symmetric', reflect_type='odd') array([0, 1, 1, 2, 3, 4, 5, 5, 6, 7]) >>> np.pad(a, (2, 3), 'wrap') array([4, 5, 1, 2, 3, 4, 5, 1, 2, 3]) >>> def pad_with(vector, pad_width, iaxis, kwargs): ... pad_value = kwargs.get('padder', 10) ... vector[:pad_width[0]] = pad_value ... vector[-pad_width[1]:] = pad_value ... return vector >>> a = np.arange(6) >>> a = a.reshape((2, 3)) >>> np.pad(a, 2, pad_with) 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]]) >>> np.pad(a, 2, pad_with, padder=100) array([[100, 100, 100, 100, 100, 100, 100], [100, 100, 100, 100, 100, 100, 100], [100, 100, 0, 1, 2, 100, 100], [100, 100, 3, 4, 5, 100, 100], [100, 100, 100, 100, 100, 100, 100], [100, 100, 100, 100, 100, 100, 100]]) Rs%`pad_width` must be of integral type.Rptconstant_valuestconstanttedget end_valuest linear_rampt stat_lengthtmaximumRFRKtminimumt reflect_typetreflectt symmetrictwrapitevens%%s keyword not in allowed keywords %sc3`s9|]/}tˆ|dˆ|dˆj|ƒVqdS(iN(RR (RR(tnarrayRr(sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pys Äss:There aren't any elements to reflect in axis {} of `array`iN(R{Rx(,R tasarrayRtkindt TypeErrorRhRqRjR6Rt isinstancetcompatt basestringRmt setdefaulttlisttrangetsumR R tzerostapply_along_axisR%R tzipR0R1R4R5R=R>RDRERIRJRNRORSRTtformatRPR_RcRg(RhRrRsRtt allowedkwargst kwdefaultstkeytkwRtfunctiontrankttotal_dim_increaset offset_slicest new_shapetnewmattiaxisRt pad_beforet pad_aftert before_valt after_valt chunk_beforet chunk_afterRVtsafe_padt pad_iter_bt pad_iter_a((R…Rrsb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyRÄsÌ             # $&       5  5 5 5 5 5       "       "     (&t__doc__t __future__RRRRwR tnumpy.core.overridesRt__all__R(RRR!R#R$R*R+R0R1R4R5R=R>RDRERIRJRNRORSRTR_RcRgRqRuR(((sb/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/lib/arraypad.pyts>   +           2 2 . 0 . 1 . 1 . 0 G D 3 G