mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-13 12:40:24 +08:00
arraypad: allow padding with zero entries (i.e. no padding).
This commit is contained in:
@@ -1085,7 +1085,7 @@ def _validate_lengths(narray, number_elements):
|
|||||||
normshp = _normalize_shape(narray, number_elements)
|
normshp = _normalize_shape(narray, number_elements)
|
||||||
for i in normshp:
|
for i in normshp:
|
||||||
chk = [1 if x is None else x for x in i]
|
chk = [1 if x is None else x for x in i]
|
||||||
chk = [1 if x > 0 else -1 for x in chk]
|
chk = [1 if x >= 0 else -1 for x in chk]
|
||||||
if (chk[0] < 0) or (chk[1] < 0):
|
if (chk[0] < 0) or (chk[1] < 0):
|
||||||
fmt = "%s cannot contain negative values."
|
fmt = "%s cannot contain negative values."
|
||||||
raise ValueError(fmt % (number_elements,))
|
raise ValueError(fmt % (number_elements,))
|
||||||
|
|||||||
@@ -518,5 +518,12 @@ def test_pad_one_axis_three_ways():
|
|||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def test_zero_pad_width():
|
||||||
|
arr = np.arange(30)
|
||||||
|
arr = np.reshape(arr, (6, 5))
|
||||||
|
for pad_width in (0, (0, 0), ((0, 0), (0, 0))):
|
||||||
|
assert np.all(arr == pad(arr, pad_width, mode='constant'))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
run_module_suite()
|
run_module_suite()
|
||||||
|
|||||||
Reference in New Issue
Block a user