Question
I don't understand why anndata wraps dask arrays with DaskArrayView. Just using regular dask arrays give the expected behavior:
import dask.array as da
import numpy as np
x = da.zeros((2, 2))
x2 = x[[0, 1]]
x2[0, 0] = 1
np.testing.assert_equal(x2.compute(), np.array([[1, 0], [0, 0]]))
np.testing.assert_equal(x.compute(), np.zeros((2, 2)))
Perhaps views of numpy arrays should follow numpy view vs. copy semantics (https://numpy.org/doc/stable/user/basics.copies.html) as other libraries like xarray?:
import numpy as np
import xarray as xr
xarray1 = xr.DataArray(np.zeros((2, 2)))
xarray2 = xarray1[0:1]
xarray2[0, 0] = 1
assert xarray1[0, 0] == 1
ad1 = anndata.AnnData(np.zeros((2, 2)))
ad2 = ad1[0:1]
ad2.X[0, 0] = 1
assert ad1.X[0, 0] == 0
Thanks.
Question
I don't understand why anndata wraps dask arrays with DaskArrayView. Just using regular dask arrays give the expected behavior:
Perhaps views of numpy arrays should follow numpy view vs. copy semantics (https://numpy.org/doc/stable/user/basics.copies.html) as other libraries like xarray?:
Thanks.