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/3245#issuecomment-780833545,https://api.github.com/repos/pydata/xarray/issues/3245,780833545,MDEyOklzc3VlQ29tbWVudDc4MDgzMzU0NQ==,2448579,2021-02-17T20:30:04Z,2021-02-17T23:22:19Z,MEMBER,"My impression was that the `as_*` methods would return xarray objects. So we could have DataArray methods
``` python
def as_numpy(self):
# needs cupy special handling
data = self.data
if isinstance(data, cupy_array_type):
raise NotImplementedError
else:
return self.copy(data=np.array(data))
def to_numpy(self):
""""""Coerces to and returns a numpy.ndarray""""""
return self.as_numpy().data
```","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,484240082
https://github.com/pydata/xarray/issues/3245#issuecomment-662778974,https://api.github.com/repos/pydata/xarray/issues/3245,662778974,MDEyOklzc3VlQ29tbWVudDY2Mjc3ODk3NA==,2448579,2020-07-23T01:35:08Z,2020-07-23T01:35:08Z,MEMBER,IMO a good first pass for `as_numpy` would be to use `np.asarray` with a special case for `cupy` where it would use `.get`.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,484240082
https://github.com/pydata/xarray/issues/3245#issuecomment-662547659,https://api.github.com/repos/pydata/xarray/issues/3245,662547659,MDEyOklzc3VlQ29tbWVudDY2MjU0NzY1OQ==,2448579,2020-07-22T16:17:02Z,2020-07-22T16:17:02Z,MEMBER,"It seems like general consensus was (please correct me if any of this is wrong):
1. `.values` will return `np.asarray(obj.data)` and respect the underlying library's choices: this will raise an error with cupy and that's OK.
2. `.plot()` is a special case and should always coerce to numpy before passing data to matplotlib. plot currently uses `.values` so we should add a new function that always returns xarray objects with numpy arrays (with cupy as special case) and use that in plot.
3. for now we are OK with special `as_sparse`, `as_cupy`, `as_pint` methods in xarray as long as all that logic is contained in one place: `as_duck_array.py`?","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,484240082
https://github.com/pydata/xarray/issues/3245#issuecomment-660209415,https://api.github.com/repos/pydata/xarray/issues/3245,660209415,MDEyOklzc3VlQ29tbWVudDY2MDIwOTQxNQ==,2448579,2020-07-17T16:34:30Z,2020-07-17T16:34:30Z,MEMBER,"I am unsure about automatic coercion for `.values`. I think we've trained users to expect numpy arrays from `.values` so `cupy` raising an error is a little unfriendly. OTOH it'd be nice to have something that is equivalent to `np.asarray(da.data)` but maybe we can expect users who want that to just type it out.
But I think we should automatically coerce for `.plot` using `da.as_numpy().data` or something similar. We call `.compute()` on dask arrays anyway so it's consistent with that behaviour.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,484240082
https://github.com/pydata/xarray/issues/3245#issuecomment-555589399,https://api.github.com/repos/pydata/xarray/issues/3245,555589399,MDEyOklzc3VlQ29tbWVudDU1NTU4OTM5OQ==,2448579,2019-11-19T16:27:26Z,2019-11-19T16:27:26Z,MEMBER,"> it makes clear that the objects are still xarray objects
This is a good point. I'm in favour of `as_sparse`, `as_dense`.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,484240082
https://github.com/pydata/xarray/issues/3245#issuecomment-555559603,https://api.github.com/repos/pydata/xarray/issues/3245,555559603,MDEyOklzc3VlQ29tbWVudDU1NTU1OTYwMw==,2448579,2019-11-19T15:28:53Z,2019-11-19T15:28:53Z,MEMBER,"I weakly prefer following the upstream API: `as_sparse` and `todense`.
though `to_sparse`,`to_dense` and `to_numpy_data` would be more consistent?
Also isn't the function `astype` not `as_type`?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,484240082
https://github.com/pydata/xarray/issues/3245#issuecomment-524408760,https://api.github.com/repos/pydata/xarray/issues/3245,524408760,MDEyOklzc3VlQ29tbWVudDUyNDQwODc2MA==,2448579,2019-08-23T18:03:17Z,2019-08-23T18:03:17Z,MEMBER,:+1: I think `to_numpy()` would be good.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,484240082
https://github.com/pydata/xarray/issues/3245#issuecomment-524388072,https://api.github.com/repos/pydata/xarray/issues/3245,524388072,MDEyOklzc3VlQ29tbWVudDUyNDM4ODA3Mg==,2448579,2019-08-23T16:57:10Z,2019-08-23T16:57:10Z,MEMBER,"The better way to phrase this is:
1. Should we formalize the convention that `.values` always return a numpy array i.e. it will call `todense()` implicitly and that `.data` will always return the underlying container: sparse/dask etc.?
2. Should we call `todense()` automatically in `plot()` the same way we do `compute()`?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,484240082