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-182496455,https://api.github.com/repos/pydata/xarray/issues/753,182496455,MDEyOklzc3VlQ29tbWVudDE4MjQ5NjQ1NQ==,1217238,2016-02-10T17:38:34Z,2016-02-10T17:38:34Z,MEMBER,"That does look strange! Please CC me when you file a numpy issue about it :).
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,132535802
https://github.com/pydata/xarray/issues/753#issuecomment-182492860,https://api.github.com/repos/pydata/xarray/issues/753,182492860,MDEyOklzc3VlQ29tbWVudDE4MjQ5Mjg2MA==,11950875,2016-02-10T17:27:51Z,2016-02-10T17:27:51Z,CONTRIBUTOR,"Interesting, thanks for looking into this. I'm sorry I didn't really put the time in to stack trace before I posted.
I think this issue can be traced back to numpy as follows:
```
float(np.array(1.)) # works
complex(np.array(1., dtype=complex)) # type error
```
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,132535802
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)
in ()
----> 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]:
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