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/pull/3117#issuecomment-511172148,https://api.github.com/repos/pydata/xarray/issues/3117,511172148,MDEyOklzc3VlQ29tbWVudDUxMTE3MjE0OA==,13301940,2019-07-14T04:25:07Z,2019-07-14T04:28:00Z,MEMBER,"@nvictus, thank you for your work!
I just tried this on CuPy arrays, and it seems to be working during array creation:
```python
In [1]: import cupy as cp
In [2]: import xarray as xr
In [3]: x = cp.arange(6).reshape(2, 3).astype('f')
In [4]: y = cp.ones((2, 3), dtype='int')
In [5]: x
Out[5]:
array([[0., 1., 2.],
[3., 4., 5.]], dtype=float32)
In [6]: y
Out[6]:
array([[1, 1, 1],
[1, 1, 1]])
In [7]: y.device
Out[7]:
In [8]: x.device
Out[8]:
In [9]: ds = xr.Dataset()
In [10]: ds['x'] = xr.DataArray(x, dims=['lat', 'lon'])
In [11]: ds['y'] = xr.DataArray(y, dims=['lat', 'lon'])
In [12]: ds
Out[12]:
Dimensions: (lat: 2, lon: 3)
Dimensions without coordinates: lat, lon
Data variables:
x (lat, lon) float32 ...
y (lat, lon) int64 ...
In [13]: ds.x.data.device
Out[13]:
In [14]: ds.y.data.device
Out[14]:
```
Even though it failed when I tried applying an operation on the dataset, this is still awesome! I am very excited and looking forward to seeing this feature in xarray:
```python
In [15]: m = ds.mean(dim='lat')
-------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
----> 1 m = ds.mean(dim='lat')
/glade/work/abanihi/devel/pangeo/xarray/xarray/core/common.py in wrapped_func(self, dim, skipna, **kwargs)
65 return self.reduce(func, dim, skipna=skipna,
66 numeric_only=numeric_only, allow_lazy=True,
---> 67 **kwargs)
68 else:
69 def wrapped_func(self, dim=None, **kwargs): # type: ignore
/glade/work/abanihi/devel/pangeo/xarray/xarray/core/dataset.py in reduce(self, func, dim, keep_attrs, keepdims, numeric_only, allow_lazy, **kwargs)
3532 keepdims=keepdims,
3533 allow_lazy=allow_lazy,
-> 3534 **kwargs)
3535
3536 coord_names = set(k for k in self.coords if k in variables)
/glade/work/abanihi/devel/pangeo/xarray/xarray/core/variable.py in reduce(self, func, dim, axis, keep_attrs, keepdims, allow_lazy, **kwargs)
1392 input_data = self.data if allow_lazy else self.values
1393 if axis is not None:
-> 1394 data = func(input_data, axis=axis, **kwargs)
1395 else:
1396 data = func(input_data, **kwargs)
/glade/work/abanihi/devel/pangeo/xarray/xarray/core/duck_array_ops.py in mean(array, axis, skipna, **kwargs)
370 return _to_pytimedelta(mean_timedeltas, unit='us') + offset
371 else:
--> 372 return _mean(array, axis=axis, skipna=skipna, **kwargs)
373
374
/glade/work/abanihi/devel/pangeo/xarray/xarray/core/duck_array_ops.py in f(values, axis, skipna, **kwargs)
257
258 try:
--> 259 return func(values, axis=axis, **kwargs)
260 except AttributeError:
261 if isinstance(values, dask_array_type):
/glade/work/abanihi/devel/pangeo/xarray/xarray/core/nanops.py in nanmean(a, axis, dtype, out)
158 return dask_array.nanmean(a, axis=axis, dtype=dtype)
159
--> 160 return np.nanmean(a, axis=axis, dtype=dtype)
161
162
/glade/work/abanihi/softwares/miniconda3/envs/xarray-tests/lib/python3.7/site-packages/numpy/core/overrides.py in public_api(*args, **kwargs)
163 relevant_args = dispatcher(*args, **kwargs)
164 return implement_array_function(
--> 165 implementation, public_api, relevant_args, args, kwargs)
166
167 if module is not None:
TypeError: no implementation found for 'numpy.nanmean' on types that implement __array_function__: []
```
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,467771005