Skip to content

Assigning data to vector-indexed data doesn't seem to work #1743

Closed
@mraspaud

Description

@mraspaud

Code Sample

import xarray as xr
import numpy as np
import dask.array as da

arr = np.arange(25).reshape((5, 5))

l_indices = xr.DataArray(np.array(((0, 1), (2, 3))), dims=['lines', 'cols'])
c_indices = xr.DataArray(np.array(((1, 3), (0, 2))), dims=['lines', 'cols'])

xarr = xr.DataArray(da.from_array(arr, chunks=10), dims=['y', 'x'])

print(xarr[l_indices, c_indices])

xarr[l_indices, c_indices] = 2

Problem description

This crashes on the last line with a

IndexError: Unlabeled multi-dimensional array cannot be used for indexing: [[0 1]
 [2 3]]

I'm expecting to be able to do assignment this way, and it doesn't work.

Expected Output

Expected output is the modified array with 2's in the indicated positions

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 2.7.5.final.0 python-bits: 64 OS: Linux OS-release: 3.10.0-693.2.2.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: None.None

xarray: 0.10.0
pandas: 0.21.0
numpy: 1.13.3
scipy: 0.18.1
netCDF4: 1.1.8
h5netcdf: 0.4.2
Nio: None
bottleneck: None
cyordereddict: None
dask: 0.15.4
matplotlib: 1.2.0
cartopy: None
seaborn: None
setuptools: 36.2.1
pip: 9.0.1
conda: None
pytest: 3.1.3
IPython: 5.1.0
sphinx: 1.3.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions