home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 991144834

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
991144834 MDU6SXNzdWU5OTExNDQ4MzQ= 5779 Coordinates have wrong number of elements after a Dataset/DataArray is split by np.split() 25172489 open 0     4 2021-09-08T13:32:49Z 2021-09-13T04:34:02Z   NONE      

What happened:

Tried to split a DataArray containing coordinates using numpy. Surprisingly, coordinates along another dimension than the axis specified to numpy are split. The resulting DataArray is broken since now the number of elements in all coordinates are different from the corresponding dimensions.

What you expected to happen:

Coordinates along the correct dimension should be split.

Minimal Complete Verifiable Example:

```python

import xarray as xr import numpy as np testarr = xr.DataArray(np.zeros((4, 6)), coords={"dim_0": np.arange(4), "aux_0": ("dim_0", ["a", "b", "c", "d"]), "aux_1": ("dim_1", np.arange(6))}) np.split(testarr, 3, axis=1) [<xarray.DataArray (dim_0: 4, dim_1: 2)> /-- array of shape (4, 2), all zero --/ Coordinates: * dim_0 (dim_0) int64 0 1 aux_0 (dim_0) <U1 'a' 'b' aux_1 (dim_1) int64 0 1 2 3 4 5 Dimensions without coordinates: dim_1, <xarray.DataArray (dim_0: 4, dim_1: 2)> /-- array of shape (4, 2), all zero --/ Coordinates: * dim_0 (dim_0) int64 2 3 aux_0 (dim_0) <U1 'c' 'd' aux_1 (dim_1) int64 0 1 2 3 4 5 Dimensions without coordinates: dim_1, <xarray.DataArray (dim_0: 4, dim_1: 2)> /-- array of shape (4, 2), all zero --/ Coordinates: * dim_0 (dim_0) int64 aux_0 (dim_0) <U1 aux_1 (dim_1) int64 0 1 2 3 4 5 Dimensions without coordinates: dim_1] ```

Anything else we need to know?:

Yes I know there's probably a better way to achieve what I need using xarray, probably xarray.apply_ufunc() or sth. Still, the observed behavior is unexpected.

Environment:

Output of <tt>xr.show_versions()</tt> ```python >>> xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.9.1 (default, Jan 13 2021, 15:21:08) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] python-bits: 64 OS: Linux OS-release: 3.10.0-1160.6.1.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.0 libnetcdf: 4.7.4 xarray: 0.18.2 pandas: 1.2.5 numpy: 1.20.3 scipy: 1.6.3 netCDF4: 1.5.6 pydap: None h5netcdf: None h5py: 3.2.1 Nio: None zarr: None cftime: 1.5.0 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2021.06.0 distributed: None matplotlib: 3.4.2 cartopy: None seaborn: None numbagg: None pint: None setuptools: 49.2.1 pip: 21.2.4 conda: None pytest: 6.2.4 IPython: 7.24.1 sphinx: None ```
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/5779/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

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