home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 334799284

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/553#issuecomment-334799284 https://api.github.com/repos/pydata/xarray/issues/553 334799284 MDEyOklzc3VlQ29tbWVudDMzNDc5OTI4NA== 630936 2017-10-06T16:07:18Z 2017-10-06T16:08:37Z CONTRIBUTOR

There is an open issue at numpy about this in https://github.com/numpy/numpy/issues/6266

Also, for future reference, locally re-defining np.angle by removing the z = array(z) line from the official function appears to work well enough as a workaround, assuming the input is an xarray, ```py import numpy.core.numeric as _nx

def angle(z, deg=0): """Compute the angle of an xarray

Parameters
----------
z : array_like
    A complex number or sequence of complex numbers.
deg : bool, optional
    Return angle in degrees if True, radians if False (default).

Returns
-------
angle : ndarray or scalar
    The counterclockwise angle from the positive real axis on
    the complex plane, with dtype as numpy.float64.

See: https://github.com/pydata/xarray/issues/553
     https://github.com/numpy/numpy/blob/v1.13.0/numpy/lib/function_base.py#L2072-L2115
"""
if deg:
    fact = 180/pi
else:
    fact = 1.0
if (issubclass(z.dtype.type, _nx.complexfloating)):
    zimag = z.imag
    zreal = z.real
else:
    zimag = 0
    zreal = z
return np.arctan2(zimag, zreal)

```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  103703011
Powered by Datasette · Queries took 0.568ms · About: xarray-datasette