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/5568#issuecomment-873238915,https://api.github.com/repos/pydata/xarray/issues/5568,873238915,MDEyOklzc3VlQ29tbWVudDg3MzIzODkxNQ==,41898282,2021-07-02T20:22:13Z,2021-07-21T22:06:47Z,CONTRIBUTOR,"## Unit Test Results          6 files  ±0           6 suites  ±0   51m 2s :stopwatch: ±0s 16 202 tests ±0  14 476 :heavy_check_mark: ±0  1 726 :zzz: ±0  0 :x: ±0  90 408 runs  ±0  82 242 :heavy_check_mark: ±0  8 166 :zzz: ±0  0 :x: ±0  Results for commit c5ee050f. ± Comparison against base commit c5ee050f. :recycle: This comment has been updated with latest results.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,936045730 https://github.com/pydata/xarray/pull/5568#issuecomment-884503023,https://api.github.com/repos/pydata/xarray/issues/5568,884503023,IC_kwDOAMm_X840uHHv,35968931,2021-07-21T21:11:58Z,2021-07-21T21:11:58Z,MEMBER,Okay thanks @shoyer - I've removed the type check and the attempt to call `.to_numpy()`.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,936045730 https://github.com/pydata/xarray/pull/5568#issuecomment-873482983,https://api.github.com/repos/pydata/xarray/issues/5568,873482983,MDEyOklzc3VlQ29tbWVudDg3MzQ4Mjk4Mw==,24736507,2021-07-03T23:15:29Z,2021-07-21T21:11:19Z,NONE,"Hello @TomNicholas! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: ##### Comment last updated at 2021-07-21 21:11:19 UTC","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,936045730 https://github.com/pydata/xarray/pull/5568#issuecomment-884323982,https://api.github.com/repos/pydata/xarray/issues/5568,884323982,IC_kwDOAMm_X840tbaO,35968931,2021-07-21T16:27:54Z,2021-07-21T16:27:54Z,MEMBER,The only error is the ffspec error now,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,936045730 https://github.com/pydata/xarray/pull/5568#issuecomment-881585044,https://api.github.com/repos/pydata/xarray/issues/5568,881585044,IC_kwDOAMm_X840i-uU,35968931,2021-07-16T16:52:56Z,2021-07-16T16:52:56Z,MEMBER,"@dcherian I think `.to_numpy()` does actually work in the case of an IndexVariable, because the underlying pandas index has that method. That's not going to be used yet, but we should perhaps leave it in to prepare for the flexible indexes? Other than that I like your other suggestions, please commit and merge as you see fit! On Fri, 16 Jul 2021, 10:44 Deepak Cherian, ***@***.***> wrote: > ***@***.**** approved this pull request. > > looks great. Thanks @TomNicholas > ------------------------------ > > In xarray/core/dataarray.py > : > > > @@ -623,7 +623,7 @@ def __len__(self) -> int: > > > > @property > > def data(self) -> Any: > > - """"""The array's data as a dask or numpy array"""""" > > + """"""The array's data as a numpy-like array"""""" > > > ⬇️ Suggested change > > - """"""The array's data as a numpy-like array"""""" > > + """""" > > + The DataArray's data as an array. The underlying array type > > + (e.g. dask, sparse, pint) is preserved. > > + > > + See Also > > + -------- > > + DataArray.to_numpy > > + DataArray.as_numpy > > + DataArray.values > > + """""" > > > ------------------------------ > > In xarray/core/dataarray.py > : > > > @@ -632,13 +632,42 @@ def data(self, value: Any) -> None: > > > > @property > > def values(self) -> np.ndarray: > > - """"""The array's data as a numpy.ndarray"""""" > > + """""" > > + The array's data as a numpy.ndarray. > > + > > + If the array's data is not a numpy.ndarray this will attempt to convert > > + it naively using np.array(), which will raise an error if the array > > + type does not support coercion like this. > > > ⬇️ Suggested change > > - type does not support coercion like this. > > + type does not support coercion like this (e.g. cupy). > > > ------------------------------ > > In xarray/core/dataarray.py > : > > > return self.variable.values > > > > @values.setter > > def values(self, value: Any) -> None: > > self.variable.values = value > > > > + def to_numpy(self) -> np.ndarray: > > + """""" > > + Coerces wrapped data to numpy and returns a numpy.ndarray. > > + > > + See also > > + -------- > > + DataArray.as_numpy : Same but returns the surrounding DataArray instead. > > + Dataset.as_numpy > > > ⬇️ Suggested change > > - Dataset.as_numpy > > + Dataset.as_numpy > > + DataArray.values > > + DataArray.data > > > ------------------------------ > > In xarray/core/dataarray.py > : > > > + > > + See also > > + -------- > > + DataArray.as_numpy : Same but returns the surrounding DataArray instead. > > + Dataset.as_numpy > > + """""" > > + return self.variable.to_numpy() > > + > > + def as_numpy(self: T_DataArray) -> T_DataArray: > > + """""" > > + Coerces wrapped data and coordinates into numpy arrays, returning a DataArray. > > + > > + See also > > + -------- > > + DataArray.to_numpy : Same but returns only the data as a numpy.ndarray object. > > + Dataset.as_numpy : Converts all variables in a Dataset. > > > ⬇️ Suggested change > > - Dataset.as_numpy : Converts all variables in a Dataset. > > + Dataset.as_numpy : Converts all variables in a Dataset. > > + DataArray.values > > + DataArray.data > > > ------------------------------ > > In xarray/core/pycompat.py > : > > > > > + self.module = duck_array_module > > + self.version = duck_array_version > > + self.type = duck_array_type > > + self.available = self.version > ""0.0.0"" > > > ⬇️ Suggested change > > - self.available = self.version > ""0.0.0"" > > + self.available = duck_array_module is not None > > > v. minor: this seems cleaner? > ------------------------------ > > In xarray/core/variable.py > : > > > +dask_array_type = DuckArrayModule(""dask"").type > > +cupy_array_type = DuckArrayModule(""cupy"").type > > +sparse_array_type = DuckArrayModule(""sparse"").type > > > import these from pycompat as earlier? > ------------------------------ > > In xarray/core/variable.py > : > > > + try: > > + data = data.to_numpy() > > + except AttributeError: > > > Isn't this always failing? Should we avoid it until such a protocol > actually exists? > ------------------------------ > > In xarray/core/variable.py > : > > > @@ -1069,6 +1069,32 @@ def chunk(self, chunks={}, name=None, lock=False): > > > > return self._replace(data=data) > > > > + def to_numpy(self) -> np.ndarray: > > + """"""Coerces wrapped data to numpy and returns a numpy.ndarray"""""" > > + # TODO an entrypoint so array libraries can choose coercion method? > > + data = self.data > > + try: > > + data = data.to_numpy() > > + except AttributeError: > > + if isinstance(data, dask_array_type): > > + data = self.compute().data > > > ⬇️ Suggested change > > - data = self.compute().data > > + data = data.compute() > > > to match the rest? > ------------------------------ > > In xarray/tests/test_variable.py > : > > > @@ -2540,3 +2542,68 @@ def test_clip(var): > > var.mean(""z"").data[:, :, np.newaxis], > > ), > > ) > > + > > + > > ***@***.***(""Var"", [Variable, IndexVariable]) > > > you could stick these in VariableSubclassObjects? Could also do that > later if it's a good idea > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > , > or unsubscribe > > . > ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,936045730 https://github.com/pydata/xarray/pull/5568#issuecomment-881144228,https://api.github.com/repos/pydata/xarray/issues/5568,881144228,IC_kwDOAMm_X840hTGk,35968931,2021-07-16T03:11:44Z,2021-07-16T03:11:44Z,MEMBER,"The only failure is the same as in https://github.com/pydata/xarray/issues/5600 , so I think this should be ready to merge.","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,936045730 https://github.com/pydata/xarray/pull/5568#issuecomment-877399596,https://api.github.com/repos/pydata/xarray/issues/5568,877399596,MDEyOklzc3VlQ29tbWVudDg3NzM5OTU5Ng==,35968931,2021-07-09T19:08:45Z,2021-07-09T19:08:45Z,MEMBER,This is actually ready for a review now @shoyer ,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,936045730 https://github.com/pydata/xarray/pull/5568#issuecomment-873291335,https://api.github.com/repos/pydata/xarray/issues/5568,873291335,MDEyOklzc3VlQ29tbWVudDg3MzI5MTMzNQ==,5635139,2021-07-02T22:50:10Z,2021-07-02T22:50:10Z,MEMBER,@TomNicholas I think that should fix it. But it's become Haskell-esque!,"{""total_count"": 1, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 1, ""rocket"": 0, ""eyes"": 0}",,936045730 https://github.com/pydata/xarray/pull/5568#issuecomment-873240344,https://api.github.com/repos/pydata/xarray/issues/5568,873240344,MDEyOklzc3VlQ29tbWVudDg3MzI0MDM0NA==,35968931,2021-07-02T20:25:33Z,2021-07-02T20:25:33Z,MEMBER,"Irritating linting error: ``` xarray/core/variable.py:1095: error: Incompatible return value type (got ""Variable"", expected ""VariableType"") [return-value] xarray/core/dataarray.py:661: error: Incompatible return value type (got ""DataArray"", expected ""T_DataArray"") [return-value] Found 2 errors in 2 files (checked 143 source files) ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,936045730