diff options
author | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2018-05-02 12:58:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-02 12:58:26 -0400 |
commit | b946795bd64d34147f3486e97246ed1f6a4a0937 (patch) | |
tree | 40ef8729559aaab09ca4ee85d5e9db2c76c806e5 /numpy/lib/arraypad.py | |
parent | 820765d762513510a8e46f108e8bc8b366127f8f (diff) | |
parent | a5f94a90adc15a4a5fb417a1fb5c6d4338b899a0 (diff) | |
download | numpy-b946795bd64d34147f3486e97246ed1f6a4a0937.tar.gz |
Merge pull request #11033 from lagru/pad
BUG: Fix padding with large integers
Diffstat (limited to 'numpy/lib/arraypad.py')
-rw-r--r-- | numpy/lib/arraypad.py | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/numpy/lib/arraypad.py b/numpy/lib/arraypad.py index daaa68d06..97ba12348 100644 --- a/numpy/lib/arraypad.py +++ b/numpy/lib/arraypad.py @@ -100,12 +100,8 @@ def _prepend_const(arr, pad_amt, val, axis=-1): return arr padshape = tuple(x if i != axis else pad_amt for (i, x) in enumerate(arr.shape)) - if val == 0: - return np.concatenate((np.zeros(padshape, dtype=arr.dtype), arr), - axis=axis) - else: - return np.concatenate(((np.zeros(padshape) + val).astype(arr.dtype), - arr), axis=axis) + return np.concatenate((np.full(padshape, val, dtype=arr.dtype), arr), + axis=axis) def _append_const(arr, pad_amt, val, axis=-1): @@ -134,12 +130,8 @@ def _append_const(arr, pad_amt, val, axis=-1): return arr padshape = tuple(x if i != axis else pad_amt for (i, x) in enumerate(arr.shape)) - if val == 0: - return np.concatenate((arr, np.zeros(padshape, dtype=arr.dtype)), - axis=axis) - else: - return np.concatenate( - (arr, (np.zeros(padshape) + val).astype(arr.dtype)), axis=axis) + return np.concatenate((arr, np.full(padshape, val, dtype=arr.dtype)), + axis=axis) def _prepend_edge(arr, pad_amt, axis=-1): |