Repository navigation
Conversation
* Previously, Zappy and dask arrays were being converted to numpy arrays, which caused tests to pass, but with the wrong behaviour.
* This is being corrected by scverse/scanpy#733, though I'm not sure how we should be dealing with dask arrays.
* Additionally, I've changed behaviour for `adata[idx].X[other_idx] = value` to making a copy-on-modify for the parent view, as it was in `<0.6.21`. I'm not totally sure if this is the intended behaviour, but it certainly is easier and now tested for.
|
Thanks for opening this @ivirshup. The principle should be that Anndata doesn't change array types to numpy arrays. It may not have done this in the past (and this is one example), but we should fix that. Hopefully with improvements in numpy itself (like https://www.numpy.org/neps/nep-0018-array-function-protocol.html, and
Yes, the idea is that they are immutable, and they are changed by transformation (e.g. applying a ufunc) to create a new array. |
* Previously, Zappy and dask arrays were being converted to numpy arrays, which caused tests to pass, but with the wrong behaviour.
* This is being corrected by scverse/scanpy#733, though I'm not sure how we should be dealing with dask arrays.
* Additionally, I've changed behaviour for `adata[idx].X[other_idx] = value` to making a copy-on-modify for the parent view, as it was in `<0.6.21`. I'm not totally sure if this is the intended behaviour, but it certainly is easier and now tested for.
I mostly agree with this, but think there would be a fair amount of work needed in AnnData. Most array types have special treatment in at least one place. A lot of this is due to our need to support sparse matrices. I'm hoping this can be reduced with some new stuff I'm adding though. This is definitely a good use case to test with. There's also the issue of when converting implicitly makes sense. We will do transformations from sparse to dense if the values becomes dense. We will also convert between sparse matrix formats if it will make calculations more efficient. On the topic of Zappy arrays. Can you take a |
|
Looking at the view code again, I see a key pain point for working with generic arrays is how our views work. Right now, we have to make a new subclass for every array type we accept, so that we can take views of arbitrary indices. |
8ecd68c to
687431b
Compare
This solves some issues with the distributed backend, Namely, most errors for scverse/scanpy#733 stop occuring. `normalize_per_cell` still fails for dask, but the array doesn't appear to get modified. This will need more looking into.
* Previously, Zappy and dask arrays were being converted to numpy arrays, which caused tests to pass, but with the wrong behaviour.
* This is being corrected by scverse/scanpy#733, though I'm not sure how we should be dealing with dask arrays.
* Additionally, I've changed behaviour for `adata[idx].X[other_idx] = value` to making a copy-on-modify for the parent view, as it was in `<0.6.21`. I'm not totally sure if this is the intended behaviour, but it certainly is easier and now tested for.
This solves some issues with the distributed backend, Namely, most errors for scverse/scanpy#733 stop occuring. `normalize_per_cell` still fails for dask, but the array doesn't appear to get modified. This will need more looking into.
|
I've managed to mostly fix this with only a slightly hacky change to AnnData (no longer requiring X to have a view type defined when making a copy). However the I've asked about this behaviour, and if it might change or throw a warning in dask/dask#5199 |
|
@aopisco This might be relevant to your questions about zarr arrays in backed/distributed mode. |
5dcb4a9 to
508f6c2
Compare
a0a95bc to
508f6c2
Compare
|
Nope, I was dumb. It's obviously that anndata hasn't been updated in this build. |
Add checks to make sure the distributed backend is staying distributed. This currently fails for dask arrays, since they become numpy arrays when subset.
@tomwhite Is this it right to assume that dask arrays should stay as dask arrays, and Zappy arrays should stay as Zappy arrays? Currently dask arrays are becoming numpy arrays when the parent AnnData is subset via the last line here (though this exact code is being replaced):
https://github.com/theislab/anndata/blob/75296bb210d141fa1de24960412bfcab77a9604d/anndata/core/anndata.py#L637-L657
Also, are
ZappyArrays always read-only like theDirectZappyArrays are? I'm wondering about the set of anndata features they should work with.