summaryrefslogtreecommitdiff
path: root/numpy/lib/arraypad.py
diff options
context:
space:
mode:
authorWansoo Kim <rladhkstn8@gmail.com>2020-07-17 14:27:44 +0900
committerGitHub <noreply@github.com>2020-07-17 08:27:44 +0300
commit6ef5ec39cdfaf77aa4600ec2e3bf9f679a4fd527 (patch)
treeea33c930ddcbfca9dbcc4bf8508c94bb3f8ff035 /numpy/lib/arraypad.py
parentd3eae8be4d783948a0d71363bc07558524e905e5 (diff)
downloadnumpy-6ef5ec39cdfaf77aa4600ec2e3bf9f679a4fd527.tar.gz
MAINT: Remove Duplicated Code (function extract rmap) (#16847)
* MAINT: Remove Duplicated Code (function extract rmap) Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Diffstat (limited to 'numpy/lib/arraypad.py')
-rw-r--r--numpy/lib/arraypad.py29
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)]