home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 1406633320

This data as json

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
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 method:

At first I used DataArray.cumsum 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') <xarray.DataArray (x: 4, y: 3)> 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 throughDataArray.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: <xarray.DataArray (x: 4, y: 3)> 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, 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 "<stdin>", line 1, in <module> 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

Links from other tables

  • 2 rows from issues_id in issues_labels
  • 2 rows from issue in issue_comments
Powered by Datasette · Queries took 0.555ms · About: xarray-datasette