diff options
| author | Charles Harris <charlesr.harris@gmail.com> | 2016-01-31 12:13:52 -0700 |
|---|---|---|
| committer | Charles Harris <charlesr.harris@gmail.com> | 2016-01-31 12:13:52 -0700 |
| commit | 3bc8ed46d0fc142efb24ddc6b444332793476819 (patch) | |
| tree | b01edce10745d8d8cfedeaa94930826fa6ac6ad6 /numpy | |
| parent | d077cf54ca10b93be826b01e52fcf8f94d6b44b9 (diff) | |
| parent | 32ae04a43ccd7a3413deb1711796280f8fa69ba0 (diff) | |
| download | numpy-3bc8ed46d0fc142efb24ddc6b444332793476819.tar.gz | |
Merge pull request #7152 from bertrand-l/fix/unicode-kwarg-breaks-pad
BUG: mode kwargs passed as unicode to np.pad raises an exception
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/lib/arraypad.py | 2 | ||||
| -rw-r--r-- | numpy/lib/tests/test_arraypad.py | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/numpy/lib/arraypad.py b/numpy/lib/arraypad.py index dad1f4764..c30ef6bf5 100644 --- a/numpy/lib/arraypad.py +++ b/numpy/lib/arraypad.py @@ -1337,7 +1337,7 @@ def pad(array, pad_width, mode, **kwargs): 'reflect_type': 'even', } - if isinstance(mode, str): + if isinstance(mode, np.compat.basestring): # Make sure have allowed kwargs appropriate for mode for key in kwargs: if key not in allowedkwargs[mode]: diff --git a/numpy/lib/tests/test_arraypad.py b/numpy/lib/tests/test_arraypad.py index 30ea35d55..f19a0b13a 100644 --- a/numpy/lib/tests/test_arraypad.py +++ b/numpy/lib/tests/test_arraypad.py @@ -953,6 +953,17 @@ class TestNdarrayPadWidth(TestCase): assert_array_equal(a, b) +class TestUnicodeInput(TestCase): + def test_unicode_mode(self): + try: + constant_mode = unicode('constant') + except NameError: + constant_mode = 'constant' + a = np.pad([1], 2, mode=constant_mode) + b = np.array([0, 0, 1, 0, 0]) + assert_array_equal(a, b) + + class ValueError1(TestCase): def test_check_simple(self): arr = np.arange(30) |
