diff options
Diffstat (limited to 'numpy/lib/arraypad.py')
-rw-r--r-- | numpy/lib/arraypad.py | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/numpy/lib/arraypad.py b/numpy/lib/arraypad.py index 7569e7651..069e1fab3 100644 --- a/numpy/lib/arraypad.py +++ b/numpy/lib/arraypad.py @@ -207,23 +207,20 @@ def _get_linear_ramps(padded, axis, width_pair, end_value_pair): """ edge_pair = _get_edges(padded, axis, width_pair) - left_ramp = np.linspace( - start=end_value_pair[0], - stop=edge_pair[0].squeeze(axis), # Dimensions is replaced by linspace - num=width_pair[0], - endpoint=False, - dtype=padded.dtype, - axis=axis, - ) - - right_ramp = np.linspace( - start=end_value_pair[1], - stop=edge_pair[1].squeeze(axis), # Dimension is replaced by linspace - num=width_pair[1], - endpoint=False, - dtype=padded.dtype, - axis=axis, + left_ramp, right_ramp = ( + np.linspace( + start=end_value, + stop=edge.squeeze(axis), # Dimension is replaced by linspace + num=width, + endpoint=False, + dtype=padded.dtype, + axis=axis + ) + for end_value, edge, width in zip( + end_value_pair, edge_pair, width_pair + ) ) + # Reverse linear space in appropriate dimension right_ramp = right_ramp[_slice_at_axis(slice(None, None, -1), axis)] |