MCPcopy Create free account
hub / github.com/numpy/numpy / _get_edges

Function _get_edges

numpy/lib/arraypad.py:154–183  ·  view source on GitHub ↗

Retrieve edge values from empty-padded array in given dimension. Parameters ---------- padded : ndarray Empty-padded array. axis : int Dimension in which the edges are considered. width_pair : (int, int) Pair of widths that mark the pad area on both

(padded, axis, width_pair)

Source from the content-addressed store, hash-verified

152
153
154def _get_edges(padded, axis, width_pair):
155 """
156 Retrieve edge values from empty-padded array in given dimension.
157
158 Parameters
159 ----------
160 padded : ndarray
161 Empty-padded array.
162 axis : int
163 Dimension in which the edges are considered.
164 width_pair : (int, int)
165 Pair of widths that mark the pad area on both sides in the given
166 dimension.
167
168 Returns
169 -------
170 left_edge, right_edge : ndarray
171 Edge values of the valid area in `padded` in the given dimension. Its
172 shape will always match `padded` except for the dimension given by
173 `axis` which will have a length of 1.
174 """
175 left_index = width_pair[0]
176 left_slice = _slice_at_axis(slice(left_index, left_index + 1), axis)
177 left_edge = padded[left_slice]
178
179 right_index = padded.shape[axis] - width_pair[1]
180 right_slice = _slice_at_axis(slice(right_index - 1, right_index), axis)
181 right_edge = padded[right_slice]
182
183 return left_edge, right_edge
184
185
186def _get_linear_ramps(padded, axis, width_pair, end_value_pair):

Callers 2

_get_linear_rampsFunction · 0.85
padFunction · 0.85

Calls 1

_slice_at_axisFunction · 0.85

Tested by

no test coverage detected