summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorAntony Lee <anntzer.lee@gmail.com>2015-08-07 16:29:55 -0700
committerAntony Lee <anntzer.lee@gmail.com>2015-08-07 19:30:28 -0700
commit19a2f21583eea74ebe012f5481e19a6252383835 (patch)
treef767f71e422c2d8ce210a00fcacfbef4d99884ce /numpy/lib
parente4d4b45d26813899c66e112365896aabbb7b19fa (diff)
downloadnumpy-19a2f21583eea74ebe012f5481e19a6252383835.tar.gz
Clarify signature of numpy.pad.
`mode` is a required argument so just declare it as such. This does not prevent it from being passed as a keyword argument.
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/arraypad.py5
-rw-r--r--numpy/lib/tests/test_arraypad.py2
2 files changed, 2 insertions, 5 deletions
diff --git a/numpy/lib/arraypad.py b/numpy/lib/arraypad.py
index f70297f48..dad1f4764 100644
--- a/numpy/lib/arraypad.py
+++ b/numpy/lib/arraypad.py
@@ -1114,7 +1114,7 @@ def _validate_lengths(narray, number_elements):
# Public functions
-def pad(array, pad_width, mode=None, **kwargs):
+def pad(array, pad_width, mode, **kwargs):
"""
Pads an array.
@@ -1355,9 +1355,6 @@ def pad(array, pad_width, mode=None, **kwargs):
if i in ['end_values', 'constant_values']:
kwargs[i] = _normalize_shape(narray, kwargs[i],
cast_to_int=False)
- elif mode is None:
- raise ValueError('Keyword "mode" must be a function or one of %s.' %
- (list(allowedkwargs.keys()),))
else:
# Drop back to old, slower np.apply_along_axis mode for user-supplied
# vector function
diff --git a/numpy/lib/tests/test_arraypad.py b/numpy/lib/tests/test_arraypad.py
index 11d2c70b1..30ea35d55 100644
--- a/numpy/lib/tests/test_arraypad.py
+++ b/numpy/lib/tests/test_arraypad.py
@@ -993,7 +993,7 @@ class ValueError3(TestCase):
def test_mode_not_set(self):
arr = np.arange(30).reshape(5, 6)
- assert_raises(ValueError, pad, arr, 4)
+ assert_raises(TypeError, pad, arr, 4)
def test_malformed_pad_amount(self):
arr = np.arange(30).reshape(5, 6)