From 48783e5ceb7f60c33db81ab72e5024f42b220990 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Fri, 24 Feb 2017 16:46:58 +0000 Subject: MAINT: replace len(x.shape) with x.ndim --- numpy/lib/function_base.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'numpy/lib/function_base.py') diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index fc49a6fd7..1cf57d617 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1674,7 +1674,7 @@ def gradient(f, *varargs, **kwargs): S0025-5718-1988-0935077-0/S0025-5718-1988-0935077-0.pdf>`_. """ f = np.asanyarray(f) - N = len(f.shape) # number of dimensions + N = f.ndim # number of dimensions axes = kwargs.pop('axis', None) if axes is None: @@ -1900,7 +1900,7 @@ def diff(a, n=1, axis=-1): raise ValueError( "order must be non-negative but got " + repr(n)) a = asanyarray(a) - nd = len(a.shape) + nd = a.ndim slice1 = [slice(None)]*nd slice2 = [slice(None)]*nd slice1[axis] = slice(1, None) @@ -2144,7 +2144,7 @@ def unwrap(p, discont=pi, axis=-1): """ p = asarray(p) - nd = len(p.shape) + nd = p.ndim dd = diff(p, axis=axis) slice1 = [slice(None, None)]*nd # full slices slice1[axis] = slice(1, None) @@ -4488,7 +4488,7 @@ def trapz(y, x=None, dx=1.0, axis=-1): d = d.reshape(shape) else: d = diff(x, axis=axis) - nd = len(y.shape) + nd = y.ndim slice1 = [slice(None)]*nd slice2 = [slice(None)]*nd slice1[axis] = slice(1, None) -- cgit v1.2.1