8000 Merge pull request #7358 from chiffa/master · numpy/numpy@e90e254 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit e90e254

Browse files
committed
Merge pull request #7358 from chiffa/master
BUG: pull request related to the issue #7353
2 parents 140552d + 3db32cb commit e90e254

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

numpy/lib/arraypad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ def _normalize_shape(ndarray, shape, cast_to_int=True):
10521052
arr = arr.repeat(2, axis=1)
10531053
elif arr.shape[0] == ndims:
10541054
# Input correctly formatted, pass it on as `arr`
1055-
arr = shape
1055+
pass
10561056
else:
10571057
fmt = "Unable to create correctly shaped tuple from %s"
10581058
raise ValueError(fmt % (shape,))

numpy/lib/tests/test_arraypad.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,19 @@ def test_check_constant_odd_pad_amount(self):
477477
)
478478
assert_allclose(test, expected)
479479

480+
def test_check_constant_pad_2d(self):
481+
arr = np.arange(4).reshape(2, 2)
482+
test = np.lib.pad(arr, ((1, 2), (1, 3)), mode='constant',
483+
constant_values=((1, 2), (3, 4)))
484+
expected = np.array(
485+
[[3, 1, 1, 4, 4, 4],
486+
[3, 0, 1, 4, 4, 4],
487+
[3, 2, 3, 4, 4, 4],
488+
[3, 2, 2, 4, 4, 4],
489+
[3, 2, 2, 4, 4, 4]]
490+
)
491+
assert_allclose(test, expected)
492+
480493

481494
class TestLinearRamp(TestCase):
482495
def test_check_simple(self):

0 commit comments

Comments
 (0)
0