home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 873222015

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/3245#issuecomment-873222015 https://api.github.com/repos/pydata/xarray/issues/3245 873222015 MDEyOklzc3VlQ29tbWVudDg3MzIyMjAxNQ== 35968931 2021-07-02T19:43:04Z 2021-07-02T20:18:11Z MEMBER

I'm trying to implement this (I wanted pint-aware plotting to work) in #5568, but not 100% sure if I'm doing it right.

~~1) Do we want these as_*, to_* methods to live in Variable or DataArray?~~

2) What about multiply-wrapped arrays? At the moment I have essentially

python def as_numpy(self) -> T_DataArray: """ Coerces wrapped data into a numpy array, and returns it wrapped in a DataArray. """ data = self.data if isinstance(data, dask_array_type): return self.load() elif isinstance(data, cupy_array_type): return self.copy(data=data.get()) elif isinstance(data, pint_array_type): return self.copy(data=data.magnitude) elif isinstance(data, sparse_array_type): return self.copy(data=data.to_dense()) else: return self.copy(data=np.array(data)) but do I actually want multiple passes, like ```python data = self.data if isinstance(data, dask_array_type): data = self.load().data if isinstance(data, cupy_array_type): data = data.get() if isinstance(data, pint_array_type): data = data.magnitude if isinstance(data, sparse_array_type): data = data.to_dense()

return self.copy(data=np.array(data))

```

3) @jacobtomlinson currently .values will extract the values of a cupy array by special-casing it, but based on the above discussion do we actually want to break that in favour of getting them via .to_numpy() instead?

4) There are _as_sparse and _to_dense methods already, but they are private and only present on Variable. Should I expose them?

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