Construct linear ramps for empty-padded array in given dimension. Parameters ---------- padded : ndarray Empty-padded array. axis : int Dimension in which the ramps are constructed. width_pair : (int, int) Pair of widths that mark the pad area on bot
(padded, axis, width_pair, end_value_pair)
| 185 | |
| 186 | |
| 187 | def _get_linear_ramps(padded, axis, width_pair, end_value_pair): |
| 188 | """ |
| 189 | Construct linear ramps for empty-padded array in given dimension. |
| 190 | |
| 191 | Parameters |
| 192 | ---------- |
| 193 | padded : ndarray |
| 194 | Empty-padded array. |
| 195 | axis : int |
| 196 | Dimension in which the ramps are constructed. |
| 197 | width_pair : (int, int) |
| 198 | Pair of widths that mark the pad area on both sides in the given |
| 199 | dimension. |
| 200 | end_value_pair : (scalar, scalar) |
| 201 | End values for the linear ramps which form the edge of the fully padded |
| 202 | array. These values are included in the linear ramps. |
| 203 | |
| 204 | Returns |
| 205 | ------- |
| 206 | left_ramp, right_ramp : ndarray |
| 207 | Linear ramps to set on both sides of `padded`. |
| 208 | """ |
| 209 | edge_pair = _get_edges(padded, axis, width_pair) |
| 210 | |
| 211 | left_ramp, right_ramp = ( |
| 212 | np.linspace( |
| 213 | start=end_value, |
| 214 | stop=edge.squeeze(axis), # Dimension is replaced by linspace |
| 215 | num=width, |
| 216 | endpoint=False, |
| 217 | dtype=padded.dtype, |
| 218 | axis=axis |
| 219 | ) |
| 220 | for end_value, edge, width in zip( |
| 221 | end_value_pair, edge_pair, width_pair |
| 222 | ) |
| 223 | ) |
| 224 | |
| 225 | # Reverse linear space in appropriate dimension |
| 226 | right_ramp = right_ramp[_slice_at_axis(slice(None, None, -1), axis)] |
| 227 | |
| 228 | return left_ramp, right_ramp |
| 229 | |
| 230 | |
| 231 | def _get_stats(padded, axis, width_pair, length_pair, stat_func): |
no test coverage detected
searching dependent graphs…