ó É9Zc@`s:dZddlmZmZmZddlZdgZed„Z d„Z dd„Z dd „Z dd „Z dd „Zdd „Zdd „Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zed„Zd„Zd„ZdS(sl The arraypad module contains a group of functions to pad values onto the edges of an n-dimensional array. i(tdivisiontabsolute_importtprint_functionNtpadc`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(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys 0siiiÿÿÿÿR(ttuplet enumerateRtnptarangetreshapetrepeat(tarrRRtreverset initshapetpadarrRtdim((RRsE/opt/alt/python27/lib64/python2.7/site-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((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt_round_ifneeded=s iÿÿÿÿc`s¥ˆdkr|St‡‡fd†t|jƒDƒƒ}|dkrotjtj|d|jƒ|fdˆƒStjtj|ƒ|j|jƒ|fdˆƒSdS(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(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys esRRN(R R RR t concatenatetzerosRtastype(RRtvalRtpadshape((RRsE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt_prepend_constMs  $"c`s¥ˆdkr|St‡‡fd†t|jƒDƒƒ}|dkrotj|tj|d|jƒfdˆƒStj|tj|ƒ|j|jƒfdˆƒSdS(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(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ‡sRRN(R R RR RRRR(RRRRR ((RRsE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt _append_constos  $c`s•|dkr|St‡fd†t|jƒDƒƒ}t‡fd†t|jƒDƒƒ}||j|ƒ}tj|j|dˆƒ|fdˆƒ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`. ic3`s3|])\}}|ˆkr'tdƒndVqdS(iN(tslicetNone(RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys §sc3`s-|]#\}}|ˆkr!|ndVqdS(iN((RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys «sR(R R RR R RR(RRRt edge_slicet pad_singletontedge_arr((RsE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt _prepend_edge‘s !c`s˜|dkrˆSt‡‡fd†tˆjƒDƒƒ}t‡fd†tˆjƒDƒƒ}ˆ|j|ƒ}tjˆ|j|dˆƒfdˆƒ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`. ic3`s>|]4\}}|ˆkr'tdƒnˆjˆdVqdS(iN(R#R$R(RRR(RR(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys Ésc3`s-|]#\}}|ˆkr!|ndVqdS(iN((RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ÍsR(R R RR R RR(RRRR%R&R'((RRsE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt _append_edge²s !c `s"ˆdkr|St‡‡fd†t|jƒDƒƒ}t||ˆdtƒjtjƒ}t‡fd†t|jƒDƒƒ}t‡fd†t|jƒDƒƒ}||j|ƒj ˆˆƒ}||t ˆƒ} || }||7}t ||j ƒtj |j|j ƒ|fdˆƒ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(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ïsRc3`s3|])\}}|ˆkr'tdƒndVqdS(iN(R#R$(RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ÷sc3`s-|]#\}}|ˆkr!|ndVqdS(iN((RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ûsR(R R RRtTrueRR tfloat64R RtfloatRRR( RRtendRR tramp_arrR%R&tedge_padtslope((RRsE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt _prepend_rampÔs    c `s"ˆdkr|St‡‡fd†t|jƒDƒƒ}t||ˆdtƒjtjƒ}t‡fd†t|jƒDƒƒ}t‡fd†t|jƒDƒƒ}||j|ƒj ˆˆƒ}||t ˆƒ} || }||7}t ||j ƒtj ||j|j ƒfdˆƒ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(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys &sRc3`s3|])\}}|ˆkr'tdƒndVqdS(iÿÿÿÿN(R#R$(RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys .sc3`s-|]#\}}|ˆkr!|ndVqdS(iN((RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys 2sR(R R RRtFalseRR R+R RR,RRR( RRR-RR R.R%R&R/R0((RRsE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt _append_ramp s    c`së|dkr|Sˆdkr,t||ˆƒSˆdk rWˆ|jˆkrWd‰qWnt‡‡fd†t|jƒDƒƒ}t‡fd†t|jƒDƒƒ}||jdˆƒj|ƒ}tj|j |dˆƒ|fdˆƒ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`. iic3`s9|]/\}}|ˆkr'tdƒn tˆƒVqdS(N(R#R$(RRR(Rtnum(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys gsc3`s-|]#\}}|ˆkr!|ndVqdS(iN((RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ksRN( R(R$RR R tmaxR R RR(RRR4Rt max_sliceR&t max_chunk((RR4sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt _prepend_maxBs    !c`s'|dkr|Sˆdkr,t||ˆƒSˆdk rWˆ|jˆkrWd‰qWn|jˆd‰ˆdk r¢t‡‡‡fd†t|jƒDƒƒ}ntd„|jDƒƒ}t‡fd†t|jƒDƒƒ}||jdˆƒj|ƒ}tj||j |dˆƒfdˆƒ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`. iic3`sC|]9\}}|ˆkr'tdƒntˆˆˆdƒVqdS(iÿÿÿÿN(R#R$(RRR(RR-R4(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys scs`s|]}tdƒVqdS(N(R#R$(RR((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys  sc3`s-|]#\}}|ˆkr!|ndVqdS(iN((RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys £sRN( R)R$RR R R5R R RR(RRR4RR6R&R7((RR-R4sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt _append_maxvs$     !c`s|dkr|Sˆdkr,t||ˆƒSˆdk rWˆ|jˆkrWd‰qWnt‡‡fd†t|jƒDƒƒ}t‡fd†t|jƒDƒƒ}||jˆƒj|ƒ}t||jƒt j |j |ˆƒj |jƒ|fdˆƒ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`. iic3`s9|]/\}}|ˆkr'tdƒn tˆƒVqdS(N(R#R$(RRR(RR4(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys Òsc3`s-|]#\}}|ˆkr!|ndVqdS(iN((RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ÖsRN( R(R$RR R tmeanR RRR RRR(RRR4Rt mean_sliceR&t mean_chunk((RR4sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt _prepend_mean®s    !c`s@|dkr|Sˆdkr,t||ˆƒSˆdk rWˆ|jˆkrWd‰qWn|jˆd‰ˆdk r¢t‡‡‡fd†t|jƒDƒƒ}ntd„|jDƒƒ}t‡fd†t|jƒDƒƒ}||jdˆƒj|ƒ}t||jƒt j ||j |ˆƒj |jƒfdˆƒ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`. iic3`sC|]9\}}|ˆkr'tdƒntˆˆˆdƒVqdS(iÿÿÿÿN(R#R$(RRR(RR-R4(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys scs`s|]}tdƒVqdS(N(R#R$(RR((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys sc3`s-|]#\}}|ˆkr!|ndVqdS(iN((RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys sRN( R)R$RR R R:R RRR RRR(RRR4RR;R&R<((RR-R4sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt _append_meanâs&     c`s|dkr|Sˆdkr,t||ˆƒSˆdk rWˆ|jˆkrWd‰qWnt‡‡fd†t|jƒDƒƒ}t‡fd†t|jƒDƒƒ}tj||dˆƒj|ƒ}t||j ƒtj |j |ˆƒj |j ƒ|fdˆƒ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`. iic3`s9|]/\}}|ˆkr'tdƒn tˆƒVqdS(N(R#R$(RRR(RR4(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ?sc3`s-|]#\}}|ˆkr!|ndVqdS(iN((RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys CsRN( R(R$RR R R tmedianR RRRRR(RRR4Rt med_sliceR&t med_chunk((RR4sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt _prepend_meds    "c`sC|dkr|Sˆdkr,t||ˆƒSˆdk rWˆ|jˆkrWd‰qWn|jˆd‰ˆdk r¢t‡‡‡fd†t|jƒDƒƒ}ntd„|jDƒƒ}t‡fd†t|jƒDƒƒ}tj||dˆƒj|ƒ}t||j ƒtj ||j |ˆƒj |j ƒfdˆƒ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`. iic3`sC|]9\}}|ˆkr'tdƒntˆˆˆdƒVqdS(iÿÿÿÿN(R#R$(RRR(RR-R4(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys vscs`s|]}tdƒVqdS(N(R#R$(RR((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ysc3`s-|]#\}}|ˆkr!|ndVqdS(iN((RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys |sRN( R)R$RR R R R?R RRRRR(RRR4RR@R&RA((RR-R4sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt _append_medOs&     "c`së|dkr|Sˆdkr,t||ˆƒSˆdk rWˆ|jˆkrWd‰qWnt‡‡fd†t|jƒDƒƒ}t‡fd†t|jƒDƒƒ}||jdˆƒj|ƒ}tj|j |dˆƒ|fdˆƒ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`. iic3`s9|]/\}}|ˆkr'tdƒn tˆƒVqdS(N(R#R$(RRR(RR4(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ­sc3`s-|]#\}}|ˆkr!|ndVqdS(iN((RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ±sRN( R(R$RR R tminR R RR(RRR4Rt min_sliceR&t min_chunk((RR4sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt _prepend_minˆs    !c`s'|dkr|Sˆdkr,t||ˆƒSˆdk rWˆ|jˆkrWd‰qWn|jˆd‰ˆdk r¢t‡‡‡fd†t|jƒDƒƒ}ntd„|jDƒƒ}t‡fd†t|jƒDƒƒ}||jdˆƒj|ƒ}tj||j |dˆƒfdˆƒ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`. iic3`sC|]9\}}|ˆkr'tdƒntˆˆˆdƒVqdS(iÿÿÿÿN(R#R$(RRR(RR-R4(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ãscs`s|]}tdƒVqdS(N(R#R$(RR((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys æsc3`s-|]#\}}|ˆkr!|ndVqdS(iN((RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ésRN( R)R$RR R RDR R RR(RRR4RRER&RF((RR-R4sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt _append_min¼s$     !c `s#ˆddkr$ˆddkr$|St‡‡fd†t|jƒDƒƒ}||}t‡fd†t|jƒDƒƒ}ˆddkr|j|ƒ}nd|krˆddkrt‡fd†t|jƒDƒƒ}||j|ƒ}d||}~n|jˆˆdd‰|jˆd‰t‡‡‡fd†t|jƒDƒƒ}t‡fd †t|jƒDƒƒ} ||| } ˆddkr¯| j|ƒ} nd|krt‡fd †t|jƒDƒƒ} || j|ƒ}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. iic3`sC|]9\}}|ˆkr'tdƒntˆdddƒVqdS(iiÿÿÿÿN(R#R$(RRR(RR(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys sc3`s-|]#\}}|ˆkr!|ndVqdS(iN((RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys "stoddc3`s3|])\}}|ˆkr'tdƒndVqdS(iN(R#R$(RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys )sic3`s<|]2\}}|ˆkr'tdƒn tˆˆƒVqdS(N(R#R$(RRR(RR-tstart(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys 5sc3`s?|]5\}}|ˆkr'tdƒntdddƒVqdS(iÿÿÿÿN(R#R$(RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys 7sc3`s3|])\}}|ˆkr'tdƒndVqdS(iÿÿÿÿN(R#R$(RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ?sR(R R RR R R( RRtmethodRt ref_slicet ref_chunk1R&t edge_slice1t edge_chunktrev_idxt ref_chunk2t edge_slice2((RR-RRJsE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt_pad_refôs>!   c `sˆddkr$ˆddkr$|St‡‡fd†t|jƒDƒƒ}t‡fd†t|jƒDƒƒ}|||}t‡fd†t|jƒDƒƒ}ˆddkrÆ|j|ƒ}nd|kr.ˆddkr.t‡fd†t|jƒDƒƒ}||j|ƒ} d| |}~ n|jˆˆd‰|jˆ‰t‡‡‡fd †t|jƒDƒƒ}|||} ˆddkr«| j|ƒ} nd|krt‡fd †t|jƒDƒƒ} || j|ƒ} 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. iic3`s@|]6\}}|ˆkr'tdƒntdˆdƒVqdS(iN(R#R$(RRR(RR(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys qsc3`s?|]5\}}|ˆkr'tdƒntdddƒVqdS(iÿÿÿÿN(R#R$(RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ssc3`s-|]#\}}|ˆkr!|ndVqdS(iN((RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys xsRIc3`s3|])\}}|ˆkr'tdƒndVqdS(iN(R#R$(RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys sic3`s<|]2\}}|ˆkr'tdƒn tˆˆƒVqdS(N(R#R$(RRR(RR-RJ(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ‹sc3`s3|])\}}|ˆkr'tdƒndVqdS(iÿÿÿÿN(R#R$(RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys “sR(R R RR R R( RRRKRt sym_sliceRPt sym_chunk1R&RNROt sym_chunk2RR((RR-RRJsE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt_pad_symIs>!   c`s2ˆddkr$ˆddkr$|S|jˆˆd‰|jˆ‰t‡‡‡fd†t|jƒDƒƒ}||}t‡fd†t|jƒDƒƒ}ˆddkrÂ|j|ƒ}nt‡‡fd†t|jƒDƒƒ}||}ˆddkr|j|ƒ}ntj|||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. iic3`s<|]2\}}|ˆkr'tdƒn tˆˆƒVqdS(N(R#R$(RRR(RR-RJ(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys Äsc3`s-|]#\}}|ˆkr!|ndVqdS(iN((RRR(R(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys Ésc3`s@|]6\}}|ˆkr'tdƒntdˆdƒVqdS(iiN(R#R$(RRR(RR(sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys ÒsR(RR R R R R(RRRt wrap_slicet wrap_chunk1R&t wrap_chunk2((RR-RRJsE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt _pad_wraps"    cC`s­|j}|dkrd |Stj|ƒ}|jdkrÔ|jd ksY|jd kr~tj|dfd|jƒ|}ql|jd kr¸|tjdd…fj|ddƒ}qld}t ||fƒ‚n˜|jdkrS|jddkr!|jd|kr!|jdddƒ}ql|jd|kr7qld}t ||fƒ‚nd}t ||fƒ‚|t kr“tj |ƒj t ƒ}ntd„|jƒDƒƒS(sZ 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), ...) iiRNRis/Unable to create correctly shaped tuple from %scs`s|]}t|ƒVqdS(N(R (RR((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pys -s(NN((NN((i(i(tndimR$R tasarrayRtonesRtnewaxisRt ValueErrorR*RRtintR ttolist(tndarrayRt cast_to_inttndimsRtfmt((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt_normalize_shapeÝs.%  %+& cC`s¶t||ƒ}x |D]˜}g|D]}|dkr;dn|^q#}g|D]}|dkrfdnd^qN}|ddks’|ddkrd}t||fƒ‚qqW|S(sÜ 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), ...) iiiÿÿÿÿs"%s cannot contain negative values.N(RgR$R`(tnarraytnumber_elementstnormshpRRtchkRf((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyt_validate_lengths0s ++ cK`sÕtj|ƒjjdks*tdƒ‚ntj|ƒ}t||ƒ}i dgd6gd6dgd6dgd 6dgd 6dgd 6dgd 6d gd6d gd6gd6}idd6dd6dd6dd 6}t|tj j ƒr°x;|D]3}|||krêt d|||fƒ‚qêqêWx&||D]}|j |||ƒq,WxQ|D]X} | dkr}t||| ƒ|| |j|dkr>t|||ƒ}t|||ƒ}q×n|d }|j|d}x‡||kst||krât(||||ƒ}t(||||ƒ}t)|||f||ƒ}||8}||8}|||7}q\Wt)|||f||ƒ}q×WnÌ|dkróx½t|ƒD]Î\}\}}|d }|j|}x‡||ksb||krÐt(||||ƒ}t(||||ƒ}t*|||f||ƒ}||8}||8}|||7}qJWt*|||f||ƒ}qWnÞ|dkrÑxÏt|ƒD]¾\}\}}|j|}x„||ksF||kr±t(||||ƒ}t(||||ƒ}t+|||f|ƒ}||8}||8}|||7}q.Wt+|||f|ƒ}q Wn|S(s¹ 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. 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]]) Rs%`pad_width` must be of integral type.tconstant_valuestconstanttedget end_valuest linear_rampt stat_lengthtmaximumR:R?tminimumt reflect_typetreflectt symmetrictwrapitevens%%s keyword not in allowed keywords %sRdiN(RpRm(,R R]Rtkindt TypeErrortarrayRlR$t isinstancetcompatt basestringR`t setdefaultRgR2tlisttrangetlenRtsumR#Rtapply_along_axistcopyR tzipR!R"R(R)R1R3R8R9R=R>RBRCRGRHRDRSRWR[(R|t pad_widthtmodetkwargsRht allowedkwargst kwdefaultstkeytkwRtfunctiontrankttotal_dim_increaset offset_slicest new_shapetnewmattiaxisRt pad_beforet pad_aftert before_valt after_valt chunk_beforet chunk_afterRKtsafe_padt pad_iter_bt pad_iter_a((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyR]sÅ              &:      5  5 5 5 5 5      "       "     ( t__doc__t __future__RRRtnumpyR t__all__R2RRR!R"R(R)R1R3R8R9R=R>RBRCRGRHRSRWR[R*RgRlR(((sE/opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/arraypad.pyts2   +  " " ! " 7 7 4 8 4 9 4 9 4 8 U T @ S -