diff options
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 320a8ec6c..cd79dd67f 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1,3 +1,5 @@ +from __future__ import division + __docformat__ = "restructuredtext en" __all__ = ['select', 'piecewise', 'trim_zeros', 'copy', 'iterable', 'percentile', 'diff', 'gradient', 'angle', 'unwrap', 'sort_complex', @@ -30,6 +32,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 +710,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]] @@ -3053,7 +3056,7 @@ def percentile(a, q, axis=None, out=None, overwrite_input=False): [ 3, 2, 1]]) >>> np.percentile(a, 50) 3.5 - >>> np.percentile(a, 0.5, axis=0) + >>> np.percentile(a, 50, axis=0) array([ 6.5, 4.5, 2.5]) >>> np.percentile(a, 50, axis=1) array([ 7., 2.]) @@ -3239,7 +3242,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): |