Description
I've turned on testing my Satpy package with unstable or pre-releases of some of our dependencies including numpy and xarray. I've found one error so far where in previous versions of xarray it was possible to assign to the numpy array taken from a DataArray.
MCVE Code Sample
import numpy as np
import dask.array as da
import xarray as xr
data = np.arange(15, 301, 15).reshape(2, 10)
data_arr = xr.DataArray(data, dims=('y', 'x'), attrs={'test': 'test'})
data_arr = data_arr.copy()
data_arr = data_arr.expand_dims('bands')
data_arr['bands'] = ['L']
n_arr = np.asarray(data_arr.data)
n_arr[n_arr == 45] = 5
Which results in:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-12-90dae37dd808> in <module>
----> 1 n_arr = np.asarray(data_arr.data); n_arr[n_arr == 45] = 5
ValueError: assignment destination is read-only
Expected Output
A writable array. No error.
Problem Description
If this is expected new behavior then so be it, but wanted to check with the xarray devs before I tried to work around it.
Output of xr.show_versions()
xarray: 0.15.1.dev21+g20e6236f
pandas: 1.1.0.dev0+630.gedcf1c8f8
numpy: 1.19.0.dev0+acba244
scipy: 1.5.0.dev0+f614064
netCDF4: 1.5.3
pydap: None
h5netcdf: None
h5py: 2.10.0
Nio: None
zarr: 2.4.0
cftime: 1.0.4.2
nc_time_axis: None
PseudoNetCDF: None
rasterio: 1.1.3
cfgrib: None
iris: None
bottleneck: None
dask: 2.11.0+13.gfcc500c2
distributed: 2.11.0+7.g0d7a31ad
matplotlib: 3.2.0rc3
cartopy: 0.17.0
seaborn: None
numbagg: None
setuptools: 45.2.0.post20200209
pip: 20.0.2
conda: None
pytest: 5.3.5
IPython: 7.12.0
sphinx: 2.4.3