8000 Backport 7358, BUG: constant padding expected wrong type in constant_values by charris · Pull Request #7558 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Backport 7358, BUG: constant padding expected wrong type in constant_values #7558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion numpy/lib/arraypad.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ def _normalize_shape(ndarray, shape, cast_to_int=True):
arr = arr.repeat(2, axis=1)
elif arr.shape[0] == ndims:
# Input correctly formatted, pass it on as `arr`
arr = shape
pass
else:
fmt = "Unable to create correctly shaped tuple from %s"
raise ValueError(fmt % (shape,))
Expand Down
13 changes: 13 additions & 0 deletions numpy/lib/tests/test_arraypad.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,19 @@ def test_check_constant_odd_pad_amount(self):
)
assert_allclose(test, expected)

def test_check_constant_pad_2d(self):
arr = np.arange(4).reshape(2, 2)
test = np.lib.pad(arr, ((1, 2), (1, 3)), mode='constant',
constant_values=((1, 2), (3, 4)))
expected = np.array(
[[3, 1, 1, 4, 4, 4],
[3, 0, 1, 4, 4, 4],
[3, 2, 3, 4, 4, 4],
[3, 2, 2, 4, 4, 4],
[3, 2, 2, 4, 4, 4]]
)
assert_allclose(test, expected)


class TestLinearRamp(TestCase):
def test_check_simple(self):
Expand Down
0