summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/function_base.py5
-rw-r--r--numpy/lib/utils.py8
2 files changed, 7 insertions, 6 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 02dd0ceaf..6acd9a36b 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -30,6 +30,7 @@ from arraysetops import setdiff1d
from utils import deprecate
from _compiled_base import add_newdoc_ufunc
import numpy as np
+import collections
def iterable(y):
@@ -707,7 +708,7 @@ def piecewise(x, condlist, funclist, *args, **kw):
y = zeros(x.shape, x.dtype)
for k in range(n):
item = funclist[k]
- if not callable(item):
+ if not isinstance(item, collections.Callable):
y[condlist[k]] = item
else:
vals = x[condlist[k]]
@@ -3239,7 +3240,7 @@ def add_newdoc(place, obj, doc):
"""
try:
new = {}
- exec 'from %s import %s' % (place, obj) in new
+ exec('from %s import %s' % (place, obj), new)
if isinstance(doc, str):
add_docstring(new[obj], doc.strip())
elif isinstance(doc, tuple):
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py
index 820e6d8f9..97f8358aa 100644
--- a/numpy/lib/utils.py
+++ b/numpy/lib/utils.py
@@ -86,8 +86,8 @@ if sys.version_info < (2, 4):
# Can't set __name__ in 2.3
import new
def _set_function_name(func, name):
- func = new.function(func.func_code, func.func_globals,
- name, func.func_defaults, func.func_closure)
+ func = new.function(func.__code__, func.__globals__,
+ name, func.__defaults__, func.__closure__)
return func
else:
def _set_function_name(func, name):
@@ -122,7 +122,7 @@ class _Deprecate(object):
import warnings
if old_name is None:
try:
- old_name = func.func_name
+ old_name = func.__name__
except AttributeError:
old_name = func.__name__
if new_name is None:
@@ -541,7 +541,7 @@ def info(object=None,maxwidth=76,output=sys.stdout,toplevel='numpy'):
print >> output, "\n *** Total of %d references found. ***" % numfound
elif inspect.isfunction(object):
- name = object.func_name
+ name = object.__name__
arguments = inspect.formatargspec(*inspect.getargspec(object))
if len(name+arguments) > maxwidth: