id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 1396401446,PR_kwDOAMm_X85AJFT1,7123,DOC: Added examples to docstrings of DataArray methods (#7123),22195223,closed,0,,,17,2022-10-04T14:41:19Z,2022-11-01T19:57:53Z,2022-11-01T19:57:22Z,CONTRIBUTOR,,0,pydata/xarray/pulls/7123,"Added examples to the docstring of the following methods: `DataArray.drop_vars()` `DataArray.reindex_like()` `DataArray.interp_like()` I will gradually edit this PR and add more examples to other methods. I'll gladly accept feedback to improve upon my work :)","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7123/reactions"", ""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 1406633320,I_kwDOAMm_X85T14Vo,7157,AttributeError raised when DataArray.reduce is called directly,22195223,closed,0,,,2,2022-10-12T18:31:33Z,2022-10-13T17:22:42Z,2022-10-13T17:22:42Z,CONTRIBUTOR,,,,"### What happened? I'm running into an issue when trying to directly use the [DataArray.reduce](https://docs.xarray.dev/en/stable/generated/xarray.DataArray.reduce.html) method: At first I used [DataArray.cumsum](https://docs.xarray.dev/en/stable/generated/xarray.DataArray.cumsum.html) to see the expected behavior: ``` >>> data = np.arange(12).reshape(4,3) >>> da = xr.DataArray(data=data, dims=['x', 'y'], coords={'x': [10, 20, 30, 40], 'y': [70, 80, 90]}) >>> da.cumsum(dim='x') array([[ 0, 1, 2], [ 3, 5, 7], [ 9, 12, 15], [18, 22, 26]]) Coordinates: * x (x) int64 10 20 30 40 * y (y) int64 70 80 90 ``` but when I'm trying to achieve the same result through `DataArray.reduce` I'm running into a numpy error, see code snippet and error traceback for details. ### What did you expect to happen? I expect to get the same output I got from calling `DataArray.cumsum`: ``` array([[ 0, 1, 2], [ 3, 5, 7], [ 9, 12, 15], [18, 22, 26]]) Coordinates: * x (x) int64 10 20 30 40 * y (y) int64 70 80 90 ``` ### Minimal Complete Verifiable Example ```Python import xarray as xr import numpy as np data = np.arange(12).reshape(4,3) da = xr.DataArray(data=data, dims=['x', 'y'], coords={'x': [10, 20, 30, 40], 'y': [70, 80, 90]}) func = xr.DataArray.cumsum da.reduce(func=func, dim='x') ``` ### MVCE confirmation - [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray. - [X] Complete example — the example is self-contained, including all data and the text of any traceback. - [ ] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result. - [X] New issue — a search of GitHub Issues suggests this is not a duplicate. ### Relevant log output ```Python Traceback (most recent call last): File """", line 1, in File ""/mnt/c/Users/GoMaN/Desktop/GoMaN/Projects/xarray/xarray/core/dataarray.py"", line 3442, in reduce var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs) File ""/mnt/c/Users/GoMaN/Desktop/GoMaN/Projects/xarray/xarray/core/variable.py"", line 1883, in reduce data = func(self.data, axis=axis, **kwargs) File ""/mnt/c/Users/GoMaN/Desktop/GoMaN/Projects/xarray/xarray/core/common.py"", line 63, in wrapped_func return self.reduce( AttributeError: 'numpy.ndarray' object has no attribute 'reduce' ``` ### Anything else we need to know? _No response_ ### Environment
C:\Users\GoMaN\miniconda3\envs\xarray-tests3.9\lib\site-packages\_distutils_hack\__init__.py:33: UserWarning: Setuptools is replacing distutils. warnings.warn(""Setuptools is replacing distutils."") INSTALLED VERSIONS ------------------ commit: f460357a9246f093d9f7a02693e577c307b0839a python: 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:51:29) [MSC v.1929 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 69 Stepping 1, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: ('English_United States', '1252') libhdf5: None libnetcdf: None xarray: 0.1.dev4331+gb33ad6d.d20221005 pandas: 1.5.0 numpy: 1.23.3 scipy: 1.9.1 netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: None cartopy: None seaborn: None numbagg: None fsspec: None cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 65.4.1 pip: 22.2.2 conda: None pytest: 7.1.3 IPython: None sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7157/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 1396366736,PR_kwDOAMm_X85AI99F,7122,DOC: Added examples to docstrings of DataArray methods,22195223,closed,0,,,0,2022-10-04T14:19:15Z,2022-10-04T15:32:23Z,2022-10-04T14:34:20Z,CONTRIBUTOR,,1,pydata/xarray/pulls/7122,"Added examples to the docstring of the following methods: `DataArray.drop_vars()` I will gradually edit this PR and add more examples to other methods. I'll gladly accept feedback to improve upon my work :) ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7122/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull