diff options
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 1a43da8b0..75a39beaa 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1309,7 +1309,7 @@ def interp(x, xp, fp, left=None, right=None, period=None): return interp_func(x, xp, fp, left, right) -def angle(z, deg=0): +def angle(z, deg=False): """ Return the angle of the complex argument. @@ -1325,6 +1325,9 @@ def angle(z, deg=0): angle : ndarray or scalar The counterclockwise angle from the positive real axis on the complex plane, with dtype as numpy.float64. + + ..versionchanged:: 1.16.0 + This function works on subclasses of ndarray like `ma.array`. See Also -------- @@ -1339,18 +1342,18 @@ def angle(z, deg=0): 45.0 """ - if deg: - fact = 180/pi - else: - fact = 1.0 - z = asarray(z) - if (issubclass(z.dtype.type, _nx.complexfloating)): + z = asanyarray(z) + if issubclass(z.dtype.type, _nx.complexfloating): zimag = z.imag zreal = z.real else: zimag = 0 zreal = z - return arctan2(zimag, zreal) * fact + + a = arctan2(zimag, zreal) + if deg: + a *= 180/pi + return a def unwrap(p, discont=pi, axis=-1): @@ -3989,11 +3992,13 @@ def meshgrid(*xi, **kwargs): `meshgrid` is very useful to evaluate functions on a grid. + >>> import matplotlib.pyplot as plt >>> x = np.arange(-5, 5, 0.1) >>> y = np.arange(-5, 5, 0.1) >>> xx, yy = np.meshgrid(x, y, sparse=True) >>> z = np.sin(xx**2 + yy**2) / (xx**2 + yy**2) >>> h = plt.contourf(x,y,z) + >>> plt.show() """ ndim = len(xi) |