home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 182448094

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/753#issuecomment-182448094 https://api.github.com/repos/pydata/xarray/issues/753 182448094 MDEyOklzc3VlQ29tbWVudDE4MjQ0ODA5NA== 1217238 2016-02-10T16:05:36Z 2016-02-10T16:05:36Z MEMBER

The error message is actually coming from NumPy here:

``` In [8]: np.array([c1, c2])


TypeError Traceback (most recent call last) <ipython-input-8-e93d24f02743> in <module>() ----> 1 np.array([c1, c2])

/Users/shoyer/dev/xarray/xarray/core/common.py in complex(self) 67 68 def complex(self): ---> 69 return complex(self.values) 70 71 def long(self):

TypeError: can't convert complex to float ```

So this might be a numpy bug, but there's not much we can do about it directly here.

Generally, the suggested work around in these types of cases is to convert the data arrays into numpy arrays before you try to put them into another array constructor using .values, e.g.,

``` In [9]: np.array([c1.values, c2.values]) Out[9]: array([[ 1.+0.j, 2.+0.j], [ 3.+0.j, 4.+0.j]])

In [10]: xr.DataArray([c1.values, c2.values]) Out[10]: <xarray.DataArray (dim_0: 2, dim_1: 2)> array([[ 1.+0.j, 2.+0.j], [ 3.+0.j, 4.+0.j]]) Coordinates: * dim_0 (dim_0) int64 0 1 * dim_1 (dim_1) int64 0 1

In [7]: np.array([c1.values, c2.values]) Out[7]: array([[ 1.+0.j, 2.+0.j], [ 3.+0.j, 4.+0.j]]) ```

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