Closed
Description
The pad
function accepts a mode
parameter which can be a callable or str. It uses the test isinstance(mode, str)
to determine which is the case. Using from __future__ import unicode_literals
makes this fail, as the isinstance
call returns False
, eventually producing a TypeError: 'unicode' object is not callable
when the mode
argument is instead called as a function.
For example, the script:
from __future__ import unicode_literals
import numpy as np
np.pad([10], 2, mode='constant')
Fails using python2.7
with the error:
Traceback (most recent call last):
File "test.py", line 4, in <module>
np.pad([10], 2, mode='constant')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/arraypad.py", line 1348, in pad
kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/shape_base.py", line 79, in apply_along_axis
res = func1d(arr[tuple(i.tolist())],*args)
TypeError: 'unicode' object is not callable
Would using the six.string_types
comparison a la this stackexchange post be a suitable fix?
Metadata
Metadata
Assignees
Labels
No labels