home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 589632313

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
589632313 MDU6SXNzdWU1ODk2MzIzMTM= 3910 In-place addition of arrays with the same coords but in a different order 31126826 closed 0     7 2020-03-28T18:27:58Z 2020-06-24T14:41:06Z 2020-06-24T14:41:06Z CONTRIBUTOR      

I have two DataArrays with the same dimension, but the index is in a different order. Adding them with A + B works fine, but the in-place addition fails.

MCVE Code Sample

```python import numpy as np import xarray as xr

n = 5

d1 = np.arange(n) np.random.shuffle(d1) A = xr.DataArray(np.ones(n), coords=[('dim', d1)])

d2 = np.arange(n) np.random.shuffle(d2) B = xr.DataArray(np.ones(n), coords=[('dim', d2)])

print(A + B) A += B ```

Expected Output

A = A + B is working fine. I would expect A += B to do the same.

Problem Description

The in-place addition A += B fails: Traceback (most recent call last): File "/home/matthieu/xarray-test.py", line 15, in <module> A += B File "/opt/anaconda3/envs/xarray-tests/lib/python3.8/site-packages/xarray/core/dataarray.py", line 2619, in func with self.coords._merge_inplace(other_coords): File "/opt/anaconda3/envs/xarray-tests/lib/python3.8/contextlib.py", line 113, in __enter__ return next(self.gen) File "/opt/anaconda3/envs/xarray-tests/lib/python3.8/site-packages/xarray/core/coordinates.py", line 140, in _merge_inplace variables, indexes = merge_coordinates_without_align( File "/opt/anaconda3/envs/xarray-tests/lib/python3.8/site-packages/xarray/core/merge.py", line 328, in merge_coordinates_withou t_align return merge_collected(filtered, prioritized) File "/opt/anaconda3/envs/xarray-tests/lib/python3.8/site-packages/xarray/core/merge.py", line 210, in merge_collected raise MergeError( xarray.core.merge.MergeError: conflicting values for index 'dim' on objects to be combined: first value: Int64Index([1, 2, 0, 3, 4], dtype='int64', name='dim') second value: Int64Index([4, 2, 3, 1, 0], dtype='int64', name='dim')

Versions

Output of `xr.show_versions()` INSTALLED VERSIONS ------------------ commit: None python: 3.8.2 (default, Mar 26 2020, 15:53:00) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.19.112-1-MANJARO machine: x86_64 processor: byteorder: little LC_ALL: None LANG: fr_FR.UTF-8 LOCALE: fr_FR.UTF-8 libhdf5: None libnetcdf: None xarray: 0.15.0 pandas: 1.0.3 numpy: 1.18.1 scipy: None 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 setuptools: 46.1.1.post20200323 pip: 20.0.2 conda: None pytest: None IPython: None sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3910/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

  • 1 row from issues_id in issues_labels
  • 7 rows from issue in issue_comments
Powered by Datasette · Queries took 0.904ms · About: xarray-datasette